Button click
You can track goals related to clicks on various buttons and links on your site. When creating such a goal, Yandex Metrica saves information about the location and properties of these elements.
When visitors of your site click buttons or links, Yandex Metrica recognizes this click and registers it as a completed goal.
Note
To locate elements on the page, Yandex Metrica uses the ID attribute or the content of the element, as well as XPATH
, which is a query language for searching nodes in an HTML document. If a clickable element is placed in the same location on multiple pages of your site, the goal will be achieved on multiple pages. For example, this applies to links in the navigation menu of your site.
Learn more about XPATH
XPATH
is a query language that you can use to locate specific elements in XML and HTML documents. You can use it to specify the path to a specific element or group of elements.
<html>
<body>
<div class="container">
<p>First paragraph.</p>
<ul>
<li>First element of the list.</li>
<li>Second element of the list.</li>
</ul>
<p>Second paragraph.</p>
</div>
</body>
</html>
To locate the second element of the list (<li>
), use the following XPATH
query:
//HTML/BODY/DIV/UL/LI[2]
To create a goal manually:
-
In Yandex Metrica, go to the Goals page in the left menu.
-
Click Add goal.
-
In the Name field, enter a name for the goal to create.
-
Select the Click on the button type of goal.
-
In the field, specify the site page that contains the button. By default, the most popular URL on the tag is shown. Click Go and select a button.
-
In Select an element mode, hover over the desired button, select it, and click Track clicks. To go to another page or open a pop-up window, select the Interaction with the site mode.
Why button selection may be unavailable
-
Click Add goal. The created goal will appear in the list of goals. Yandex.Metrica will start collecting statistics on it within a few minutes.
-
Check whether the goal is working correctly.
Alert
Before using this type of goal in ads, check that the goal is set up correctly and that it can be achieved on your site. If you change the HTML structure of your site, the goal may not work correctly.
Goal completion is registered when a user clicks the clickable element. To view goal statistics, use the Conversions report and add the goal to other Yandex Metrica reports.
Restrictions
-
This type of goal can’t be used in Multi-step goals.
-
The service registers a user reaching the same goal on the same counter no more than once per second.
-
During a single user session, the service can register up to 1000 offline conversions and 400 online conversions created for the tag.
-
If you use iframes on the page, it might not work as expected.
-
If you edit the tag or a goal, all the previously collected information does not change.
-
If you delete a goal, information collected for it is no longer available in reports.
Questions and answers
Will the goal work without Session Replay?
If Session Replay is not enabled in the tag settings, the goal can work without it.
Will the goal for the previous version’s tag code work?
The goal may work for the previous version of the tag code.
Will the goal work with the filter Replace https with http
?
If the action Change from https to http is enabled in the tag settings on the Filters tab, button selection is not available.
Does the goal work with redirects?
If the page where you want to select a button redirects to another one, then button selection is not available. To track clicks on a specific button, use Goal through JavaScript event
.
Why can’t I see button selection?
If your website uses a Content Security Policy, add the Yandex Metrica domains to the list of exceptions.
Learn more
Useful links |
Online training |