Home Computers How to create and configure a JavaScript event type goal in Yandex.Metrica? Main goals in Yandex.Metrica that need to be tracked Setting up goals in Yandex Metrica javascript event.

How to create and configure a JavaScript event type goal in Yandex.Metrica? Main goals in Yandex.Metrica that need to be tracked Setting up goals in Yandex Metrica javascript event.

Click the edit counter button.
2. Go to the “Goals” tab, click “Add goal”.
a) Setting a goal for the number of website pages viewed.

Switch the "Conditions" tab to the "Number of views" position. Indicate the name of the goal and the number of pages that a site visitor must view to achieve it. Click "Add target".

B) Setting the goal to the "page URL".

Example for the "Product Catalog" section. If you select “url: contains” in the page URL field and specify the “products” part of the url, then the system will record visits to any page in the “Product Catalog” section.

If you select “url: matches” in the page URL field, then you need to indicate the full url “http://site.ru/products/111111”. In this case, the visit to the specified page will be recorded.

If in the page URL field you select “url: starts with” and specify the part “http://site.ru/products/category”, then in this case visits to any page in the product catalog section will be recorded.

Similar to the example, you can set the following goals:

Url: matches - site.ru/posts (News)
url: matches - site.ru/articles (Articles)
url: matches - site.ru/services (Services)

Url: matches - site.ru/products (Product catalog)

Url: matches - site.ru/delivery (Delivery)

Url: matches - site.ru/photoalbums (Photo album)

Url: matches - site.ru/video (Video)

Url: matches - site.ru/comment (Comments)

Url: matches - site.ru/contacts (Contacts)

Url: matches - site.ru/documents (Documents)

Url: starts with - site.ru/subscribe (Web version of the mailing letter)

Url: contains - products/search (Catalogue search)

Url: contains - find?q= (Google search)

Url: contains - search?searchid= (Yandex.Search)

Url: contains - confirm (Newsletter subscription)

Url: contains - unsubscribe

Url: contains - order-form (Opening a service or product form when the cart is disabled)
url: contains - order-send (Service order has been placed)
url: contains - order-made (Ordering a product with the cart disabled)

Url: contains - one-click-form (Opening the "Order in 1 click" form)
url: contains - checkout-order-by-click (Sending the completed "Order in 1 click" form)

Url: contains - feedback (Opening the "Write to us" feedback form)

Url: contains - top-form-0 (Clicking on the "Submit" button in the "Write to us" feedback form)

Url: contains - thankyou-form-0 (Successful submission of the "Write to us" feedback form)

Url: contains - callback (Opening the "Callback" feedback form)

Url: contains - top-form-1 (Clicking on the "Submit" button in the "Call Back" feedback form)

Url: contains - thankyou-form-1 (Successful submission of the "Call Back" feedback form)

Url: contains - lead-form-send (Clicking on the "Send" button in the lead form)

Url: contains - thankyou-lead-form (Successful submission of lead form)

Setting up a shopping cart goal:

Url: contains - products/viewcart (Cart)

Url: contains - cart/checkout (Order placed)
url: contains - pay/success (Successful payment)

C) Composite goal for placing an order.

Hi all! This is Evgeny Tridchikov and today we will figure out how to set up goals in Yandex Metrica. In you can learn about the basic settings, and now we will deal with conversion tracking.

How to set up goals in Metrica?

First, go to your Yandex account (log in to your email), go to metrika.yandex.ru and get to the Metrica main screen. Click on the gear and go to the “Goals” section.

As you can see, I already have some goals set up for this project. Yours will most likely be empty. Now I will talk about what types of goals Metrica allows you to track and how to work with them.

Let me remind you that without installing Metrics and goals, there is a hole in your wallet, because you will not receive information about users performing the actions you need on the site.

To start, you will have two tabs: Conversion Goals and Retargeting Goals. The division is purely conditional (perhaps it makes sense when working with large projects, when there are really a lot of goals), I have not found any practical use for it, so you can choose any tab - I usually use Conversion. This will not affect further settings and operation of Metrica in any way.

Click “Add Goal” and look at the types of available goals.

Goal "Number of views"


  • The “Name” field allows you to specify the name of the target - used for yourself.
  • The “Retargeting” checkbox will move the goal to the Retargeting section.

Metric reports work with visits. Therefore, the “Number of Views” goal will be achieved when the specified (or more) number of pages that you specify in this box are viewed during one visit.

It makes sense when working with content projects to draw conclusions about user engagement. Or, for example, on a landing page with a “Thank you page” (2 pages will be viewed only by those who leave a request).

Goal "Page Visits"


Button “Add condition” - allows you to set an additional condition for fulfilling the goal. For example, visiting several pages within a visit.

The goal will be achieved when within one visit there is a transition to the URL of interest to us. Click on the drop-down list to set the fulfillment criteria.

I usually use "url: contains" and enter the tail of the landing page in the field. For example, after filling out a form on a website, the user is taken to the “Thank you page”, which has the URL - site.ru/ thanks.


This goal describes visiting a page whose address contains the combination of characters thanks

This page will only be seen by those who fill out the form on the site. When setting a goal, I enter the word in the field - thanks. This way, I can collect the audience of those who converted (reached the landing page), and then subtract this audience from the entire site audience and catch up with them using Retargeting. More on this in the next article.

Target: JavaScript event


Using this type of goal, you can track events on the site. The most common example in my case is tracking forms on a website, when sending an application occurs without reloading the page.

In order to track only successfully submitted forms, you need to hang the following design on the form:

onsubmit =" yaCounter XXXXXXXXX.reachGoal(‘ GOAL‘); return true;"

  • where ХХХХХХХХ is the number of the Yandex Metrica counter installed on the website,
  • and GOAL is the goal identifier that will be forwarded to Yandex Metrica.

The same identifier that needs to be placed in the “Target ID” field in the target settings. And now a live example on the website jurist-pro.by.


If a person fills out the form, an event with an identifier will be sent to Metrica ClickSendForm(see screenshot). And if we enter it in the goal settings, we will be able to track this action in Yandex Metrics reports.

In general, for lawyers, the event flies to both Metrica and Google Analytics, but this approach does not always work, so I personally prefer the old-fashioned but win-win “Thank you page”. More details about Google Analytics in the next article.

Composite Goal


A composite goal in Yandex Metrica is used to get a visual representation of the sales funnel. Suitable for use when working with online stores, when you can specify individual user steps on the path to purchase.

For example, the first step could be clicking on the “Add to Cart” button, the second – “Visiting the cart”, the third – “Checkout”, the fourth – “Confirmation or Payment”. Based on the accumulated statistics, the composite goal is clearly presented in the form of a funnel with indicators for each step.

Another option for using a compound goal is when working with a landing page that has several buttons that open one pop-up form or several forms that lead to one “thank you” page. In this case, we can create chains for each form to understand which button/form is most popular among users. And below is a live example when working with kotovrealty.ru.


In the screenshot above is the Conversions report. I marked the funnel buttons with arrows: as you can see, you can view the funnel for the entire composite goal and for an individual step. This is what happens if we want to look at the funnel for a composite goal:


As you can see, thanks to the composite goal, we can get detailed statistics on the operation of the “Order a call” button in the header on one screen. Out of 786 visits, 45 (that is, 5.73%) clicked on the button, and 21 out of 45 ordered a call. There are many buttons on the site, so we monitor the operation of each link.

Another important point that is a plus in setting goals in Yandex Metrica is that the compound goal here, unlike Google Analytics, allows you to work with both URLs and events.

In Google Analytics, you can visualize a funnel only using URL goals. Thus, analytics often has to use virtual pages. In Metrica, steps of a composite goal can also be specified using events.

Well, that’s probably all I wanted to tell you about setting goals in Yandex Metrica. I really hope it’s clear and you can figure it out. In my work, in most cases I use: URL goal, event goal, and less often a compound goal.

If something remains unclear to you, feel free to write in the comments. I look at them almost daily and would be happy to help with advice.

The first thing a marketer checks at the beginning of the working day is web analytics systems. How many users came in a day, where they came from, what target actions they performed and whether they took place at all. Goals are responsible for the last point.

Technically, setting up goals is not difficult (we will show this below), but choosing which goals to set up on the site is a problem.

There are 4 types of goals in Yandex.Metrica:

  1. Number of page views.
  2. Visiting pages.
  3. JavaScript event.
  4. Composite goal.

Each type can be conversion or retargeting.

In this article we will analyze all the options for goals in Yandex.Metrica, how to choose the right ones so as not to spoil the analytics, how to set them up and what conclusions can be drawn based on them.

Conversion and retargeting goals in Metrica - what's the difference?

To make a goal retargeting, check the appropriate checkbox in the goal settings.


You can check this box later if you missed it.

How to set up a Views goal

Useful for blogs, media, entertainment and educational portals, and anywhere where you need to evaluate engagement.

On corporate websites where there is a large catalog of products, this goal can be used as a micro-conversion - “Viewed X pages” will indicate the user’s interest. You can “catch up” with it using retargeting in Yandex.Direct.

Nuances:

Metrica counts not only a transition, but also a page update as a “view.” If the user refreshes the page while on the page, this will count as 2 views. In our experience, many such “views” end up in the statistics. Therefore, you should not count viewing 2-3 pages as engagement. For this purpose, choose to view at least 4-5 pages.

How to set up "Page Visits"

You can set multiple conditions. Then the OR operator will operate between them (visited either this page or this one).

Let's say we need to track how many people made a payment on the site. To do this, we will record the transition to the Thank you page - the page the client lands on only after payment. In this case, we have 4 conditions:


url: contains: The goal will be achieved if the user visits any page that has the word done in the url. For our task, the tactics are unsuccessful - what if more pages with such a word appear?

url: matches: The goal will be achieved if the page address exactly matches the one specified in the goal. This task is suitable if there is no dynamic parameter on the page (for example, order number or user id in the system).

url: starts with: The goal will be achieved if the user visits any page starting with the given part of the url. The beginning from our example is also not suitable - it can be not only on the page after the order, but also on the checkout page.

Let's go back to the example. Let's say that after payment the order number is inserted into the url: order_id=1234. To record transitions to each page, we add the parameter - /d(4) instead of numbers. /d means that there is a number in this place, and (4) that it consists of four digits.

Nuances:

A popular mistake is to set up the goal “Went to Contact page”. Passed does not mean called or wrote. Such a goal can speak about conversion only in cases where the contacts are no longer written on any other page.

How to set up a JavaScript event

Using this goal, you can record a click on a button, submission of a completed form, and other actions directly related to the click.

Setting up a button click target

Find out how many users clicked on the “Order” button.

  • Enter the goal identifier in Metrica.

    Write it in Latin letters and so that you understand what action was performed. For example, for the “Order” button you can specify the zakazat identifier. Important: the identifier and text in the page url must not match.

  • Add a parameter to an element in the site code. The button can be easily found using the word button.

The initial code might look like this:



Add the required parameter:

); return true; " value="Order" />!}

In place of units you need to indicate the number of your Metrica counter, in place of zakazat - your identifier.

Setting up a form submission goal

Therefore, we need another parameter - onsubmit.

  • Enter the goal identifier in Metrica. Let's leave "zakazat".
  • Add a parameter to an element in the site code. The form can be found using the phrase form action.

Add a parameter:

zakazat"); return true;">

In the place of units is your meter number, in place of zakazat is your identifier.

Nuances:

  1. It is important not to confuse the onclick and onsubmit parameters. In the first case, you will track the fact of the click, even if the form is not filled out; in the second, you will track the successful submission of the form.
  2. Some buttons are located inside third-party services - online consultant, call back widget, etc. To transmit a goal that the user has performed an action on them, you need to set up synchronization of the service with your Metrics counter - in most cases this is one-button synchronization. Goals will be created automatically (for example, such goals are sent by Callibri). Please take this into account when choosing a service - if it does not transmit data to Metrica, you will not be able to track user conversion actions - messages, call requests, etc.

How to set up a "JavaScript event" on Tilda

For sites on Tilda, the goals are “click on a button”, “submit an application”, etc. are configured through “Page Visits”.

For each pop-up (pop-up window), button and form, Tilda generates a virtual page that has its own url. To get it, go to the element settings and check the “Send click data to the analytics system” checkbox.

There is no need to check the box for forms - data about them is transferred automatically.

To track clicks and form submissions, copy the virtual page url from the element settings and paste it into the “url matches” condition in the “Page Visits” goal:

How to set up a Composite Goal

Using a composite goal, you can find out at what step in the registration, checkout, or other process a user leaves.

It can be composed of the “Page Visits” and “JavaScript Event” goals. You can set up to 5 steps in total.

All settings are made in accordance with the target type.

For the chain to work correctly, the steps must be chosen so that each subsequent step is impossible without the previous one. For example, you cannot go to the cart without clicking on “Order”, you cannot get to the Thank you page without paying, etc.

How to track calls in Yandex.Metrica

The metric can only track actions on the site, and a call is an offline action: the user sees the number from a computer, and makes the call from a phone (if he has not accessed the site from a mobile phone, of course). But calls also need to be counted - without them the statistics will not be reliable.

Call tracking replaces your real number on the website and shows each user a unique phone number. When a user calls, call tracking records all the data about the visit: source, UTM tags and much more. You can study all the data on calls right inside the service, but it will also transfer the “Call” goal to Metrica, you just need to set up synchronization. Connect call tracking

How to check the operation of goals and why they may not work?

Once you have set your goals, you need to check if they are working. Open a new window in your browser in incognito mode (in Opera this is called a “Private Window”).

To check the target "Number of pages" just visit the required number of pages. The achieved goal will be displayed in Metrica approximately 5 minutes after the action.

To check the target "Page View":

  1. Open your site in debug mode, to do this, substitute it in the url ?_ym_debug=1. In our example it will be site.ru?_ym_debug=1.
  2. Open your browser console. IN Chrome: Right-click - view the page code. IN Opera And Firefox- Ctrl+Shift+K. IN Internet Explorer- F12 and the arrow in the upper right corner. IN Safari- enable the display of the “Development” menu in the browser settings, right-click on the page - check the object.
  3. Take the target action. Find the PageView line. The url of the page from the target should appear in it.
  4. Check the data in Metrica.

Target "JavaScript event" is checked in the same way:

  1. Open your site in debug mode.
  2. Open your browser console.
  3. Take the target action. Check that the reachGoal method, which we added to the site element earlier, appears in the console.
  4. Check the data in Metrica.

Composite Goal is checked as "Page View" And "JavaScript event".

Why the goal may not work:

  • The site does not have a Metrica counter installed.
  • The metric does not take into account your actions (you are not in incognito mode).
  • The target is blocked by antiviruses and ad blockers.
  • Actions on the site do not correspond to the goals specified in the settings.
  • In the case of "JavaScript Event", the reachGoal method may not be correctly added to the element.

If you have checked everything, but the goal does not work, contact your webmaster.

How to build a report by goals


What goals should you set?

Use common sense when setting your goals. Goals like “JavaScript event” will definitely be useful to you - with their help you will track clicks on the necessary buttons (Order, Add to cart, etc.).

A compound goal comes in handy when you need to track a user's journey on a website. For example: put it in the cart, filled out the contact form, paid. This way you can find out at what step the user leaves.

The Page View goal can have many purposes. But viewing the “Contacts” page can hardly be considered as “contacted”.

If you use third-party services - online consultant, call back widget, etc. - don’t forget to set up their synchronization with Metrica. Then goals like “Wrote in chat” will also be displayed.

And to add call data to your statistics, use Callibri call tracking. It will record everyone who calls you. You can even listen to calls and evaluate their quality. He will also transfer the goals to Metrica. Try call tracking Subscribe to updates:

Setting up goals in Metrica is needed to track specific actions of site visitors and evaluate the effectiveness of advertising campaigns in Yandex.Direct. After collecting data for a certain period, you will find out from which ads visitors most often perform the target action.

After analyzing the statistics, you can make the necessary adjustments to your advertising campaign. As a result, the costs of promoting goods/services will decrease and profits will increase.

What goals are important to set?

First of all, statistics require information about the audience’s actions with the main elements of the site. They are conventionally divided into three groups.

  1. Sales.
    • Click on the order button.
    • Adding an item to the cart.
    • Go to cart.
    • Filling out confirmation and payment forms.
    • Final purchase processing.
    • Product comparison.
    • Download price list.
    • Order a call back.
  2. Information about the company. This category of actions includes user transitions to the pages “Contacts”, “About the company”, “Terms of payment and delivery”, “Licenses”, “Certificates”, etc.
  3. Interest (the goals of this group are especially important for information resources). This includes: depth of page viewing, transitions to articles on similar topics, time spent by the user on the site, etc.

Types of goals in Yandex.Metrica

Goals that can be flexibly configured in Yandex.Metrica are classified into 4 types.

  • Event (JavaScript). The goal is focused on tracking specific user actions.
  • Visiting pages. Visits to important pages on the site are controlled.
  • Number of views. Configured to determine interest.
  • Composite goal. Represents a chain of steps that may include events and page visits.

What is it for

Consider a standard online store site where users can fill a cart and buy selected products. In this case, you need to set up a composite goal - a sales funnel; usually in Metrica it includes the following sequence of actions:

  • click on the add item to cart button;
  • go to cart;
  • finalize your order.

After setting up a goal in Yandex.Metrica, detailed information on each stage becomes available.



This data helps to find out how many potential customers abandon purchases and at what point. In most cases, if users don't click through to their cart, they're unhappy with the prices. Refusal to confirm a purchase may indicate the lack of a convenient payment method or too many fields in the form that a potential customer must fill out.

Instructions for setting goals in Yandex.Metrica

Number of views

This is the simplest, but very useful goal. With its help you can obtain the following information:

  • how well the site structure is developed;
  • are there any problems with navigation;
  • whether the linking was done correctly;
  • is it convenient to use;
  • how useful and high-quality content is placed on the pages;
  • Do visitors to the web resource want to study the information presented in depth?

Setting up this goal in Metrica is especially relevant for owners of websites of three categories.

  • "Information specialists". Here it is important to know whether visitors go to articles with similar topics.
  • Educational sites. Ease of navigation and quality of training materials become important.
  • Commercial sites with thematic blogs and articles.
  1. Go to the "Goals" section.
  2. Select the “Number of Views” type and come up with a name.
  3. Specify the required number of views
  4. Click the "Add Target" button.
  5. Click the Save button at the bottom of the Goals page.


As you can see, everything is simple.

Page visits

A more difficult to set up goal that allows you to track user visits to certain pages of the site. Most often it is installed to obtain answers to the following questions:

  • Is the linking done correctly?
  • Are links to important pages in the right places?
  • Are users getting to the point of taking targeted actions?

Setting up such a goal in Yandex.Metrica is especially relevant for owners of trading platforms and service sites. It helps determine whether customers go to cart, complete checkouts, what products/services they are most interested in, whether they are researching information about payment/delivery methods, etc.

The setup goes like this.

  1. Select the "Settings" menu item.
  2. Go to the "Goals" section.
  3. Click the "Add Target" button.
  4. Specify the necessary condition (we will discuss them below).
  5. Paste the link into the "Value" field.
  6. Click the "Add Target" button.


Types of conditions:

  • "Url: begins." Used to track groups of pages with the same start addresses. An ideal example is product cards for a specific catalog section.
  • "Url: matches." This condition is specified to track visits to specific pages.
  • "Url: contains." Allows you to evaluate traffic to dynamic pages. The “tails” of addresses are usually indicated here.
  • "Url: regular expressions." Instead of links, expressions from metacharacters are indicated. All the details .

Note! You can set up to 10 conditions for one goal. Completing any of them is considered achieving the goal.

Events (JavaScript)

This goal helps track user actions with all elements placed on the site: buttons, forms, checklists, etc. It is widely used in analyzing the performance of trading platforms and sites with services.

Configuring this goal allows you to:

  • calculate the number of clicks on the “Buy”, “Add to cart”, “Check out” buttons, etc.;
  • find out which product characteristics are of most interest to users (if the selection of parameters is implemented using a checklist);
  • determine whether users are interested in information hidden under spoilers, etc.

As a result, you will receive information about which interactive elements on the site work and which do not.

To set up such a goal in Yandex.Metrica, follow the following procedure.

Stage 1. Create a goal

  1. Select the "Settings" menu item.
  2. Go to the "Goals" section.
  3. Click the "Add Target" button.
  4. Note its type and come up with a name.
  5. Specify the target ID.
  6. Click the "Add Target" button.


Note! Identifiers should not partially or completely coincide with site page addresses. You can only use Latin characters and numbers, as well as underscores.

Stage 2. Adding an identifier to the page’s html code

In order for Metrica to start recording goal achievement, you need to convert the html code of the element on the page. You will find codes for buttons, link forms and other elements.

The general principle looks like this:

  1. Select the appropriate standard code (on the page via the link above) and change it to suit you (you need to enter the counter number and the name of the target identifier in Metrica).
  2. Open the landing page of the site and look for the desired element.
  3. Right-click on it and select “View code” in the menu that appears.
  4. Copy the line highlighted in the console.
  5. Go to the root directory of the site via FTP.
  6. Find the file with the source code of the page and open it.
  7. Look for the copied line in the code (the search menu opens when you press Ctrl+f).
  8. Add to it (before the closing tag) the code obtained in step 1.
  9. Save the file.

Note! If you are not sure about something, make a backup copy of the file.

Composite Goals

Composite goals are best for measuring the performance of sales funnels. They represent chains of actions that the user must perform.

When setting up composite goals in Metrica and analyzing data, consider the following important features:

  • maximum number of steps - 5;
  • to achieve the goal, the steps must be completed in a given sequence;
  • there may be other actions in between;
  • If the user is interrupted during the execution of actions for at least a period set as a timeout, achieving the goal is not counted.

To set up compound goals in Yandex.Metrica, proceed as follows:

  1. Select the "Settings" menu item.
  2. Go to the "Goals" section.
  3. Click the "Add Target" button.
  4. Note its type and come up with a name.
  5. Add the required number of steps, name them and indicate all conditions.
  6. Click the "Add Target" button.


We figured out the settings. Now we’ll tell you how to check the functionality of the goals.

Checking goals

There are two ways to make sure that everything is working correctly.

Method 1. Manually checking goals in Metrica

  1. 20 minutes after setting the goal, open “Metrica” and select the “Settings” menu item.
  2. Go to the "Filters" section.
  3. Disable the "Do not track my activities" option.
  4. Complete the target action.
  5. After a while, check whether the counter recorded the event in the Conversions report.

Method 2: Checking targets using the browser console

  1. Add “?_ym_debug=1” to the landing page address in your browser.
  2. Press Ctrl+Shift+J - the console will open.
  3. Complete the target action.

If everything is in order, a message will appear in the console indicating that the data has been transferred to the counter.


The absence of a message indicates that the goal is not working.

Why goals may not work

There are three main reasons that apply to all types of goals.

  1. The counter on the page is not set or set incorrectly.
  2. The work of Metrica is blocked by any extensions (for example, Adblock Plus) or other scripts.
  3. The visitor left the page before the counter loaded.

Events (JavaScript)

Events usually don't work in the following cases:

  • The identifiers (on the landing page and in the counter settings) do not match.
  • The reachGoal method call code is missing.
  • The reachGoal method is added correctly, but the event that calls it does not occur for some reason.
  • The reachGoal method fires before the counter is loaded.

Page visits

  • The page address is not specified in the target settings.
  • The link was entered incorrectly.
  • The site page addresses contain the # symbol.
  • An incorrect condition was selected in the target settings.
  • The page has a cyclic redirect installed.

Composite Goals

  • The conditions of one or more steps cannot be met for some reason.
  • The last steps can be completed without completing the first.

As you can see, there are many reasons for the failure of established goals. To troubleshoot problems, first check that all settings are correct. If everything is fine, dig deeper or contact the professionals.

In the last article I talked about . Today it’s time to figure out how to make sure that conversions go to Yandex Metrica. This can also be done quickly and easily. And you don't need to have programming knowledge.

Therefore, right now (with the console and debug enabled) I am doing a test conversion - sending a request through the form on the website. And... what do we see!


As you can see, the debug reports that a target with id = send was successfully sent to Metrica. And indeed, in Metrica I have an event configured with the following identifier:

As you can see, to check the operation of goals in Metrica, you do not need to have programming knowledge. All you need to do is follow three simple steps:

  • enable the code debugger in the browser;
  • enable the goal debugger in Metrica (add a tail to the page url);
  • send a test conversion.

That's all for me guys. Please like if this article was useful and ask questions in the comments if anything remains unclear!

New on the site

>

Most popular