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:

  1. In Yandex Metrica, go to the Goals page in the left menu.

  2. Click Add goal.

  3. In the Name field, enter a name for the goal to create.

  4. Select the Click on the button type of goal.

  5. 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.

  6. 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.

  7. 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.

  8. 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.

Revenue transfer β

Warning

Sending revenue data is currently in public beta testing. If your site meets the requirements for this feature, but you're experiencing issues while using it, please contact us.

To transmit revenue shown on the page with the button when the Button click goal is achieved, you can select it when setting up the goal:

  1. In the Select an element mode, select the button for which you want to track clicks.
  2. On the bottom panel, click Specify revenue. The element selection mode will be activated on the page with the relevant content.
  3. Select the unit that contains the numerical value of the revenue received when a user clicks the selected button.
  4. Click Track clicks and complete the goal setup in the Yandex Metrica interface.

You can specify the revenue currency for this type of goal in the tag settings.

Alert

Revenue value will be sent after each button click. If your website doesn't check that users complete the required fields, clicking a button multiple times can send the revenue data multiple times, and this will be added together in your reports.

To verify the accuracy of the transmitted data, follow the instructions.

Recommendations and limitations
  • A content element with revenue value should have a unique XPATH path or attributes ID or CLASS in the webpage structure. If HTML page changes, revenue may not be transmitted or may be transmitted incorrectly.
  • For correct data transmission, the element must contain a numerical value.
  • The content element with the revenue value must be located on the same page as the button or form when the goal is achieved.
  • If a button click or form submission immediately takes users to a different page, the goal may not register for users with outdated browsers, slow devices, or slow internet.
  • To prevent duplicate goal submissions with the same revenue, we recommend adding a check to the button to ensure all conditions for goal submission are met.

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

Chat with us

Write an email

Goals in Yandex Metrica work the same way for any sources. Perhaps there aren’t any users who have completed the goal from this source yet.

The recommendations did not help

Please note: Our support team will never initiate a call to you. Do not follow any instructions of people who call you and introduce themselves as the Yandex Metrica support team.

This might happen for the following reasons:

  • The goal condition in Yandex Metrica doesn't cover all the possibilities. For example, the goal is set as going to the order confirmation page, but the site also allows instant checkout without visiting this page.
  • The site user has a browser plugin that blocks the Yandex Metrica tag, so this user isn’t counted.
  • The user has an antivirus system with strict privacy settings.
  • The user has a slow internet connection, so the Yandex Metrica tag didn’t load on the target page.
The recommendations did not help

Please note: Our support team will never initiate a call to you. Do not follow any instructions of people who call you and introduce themselves as the Yandex Metrica support team.