Goals on Turbo pages created in Yandex Webmaster
Goals for an informational site
To track the users' interaction with the Turbo page elements, use a “JavaScript event” goal.
-
Add the
turbo:goal
element to an RSS feed:... <turbo:goal type="yandex" turbo-goal-id="goal-link" name="TARGET" id="12345" /> <turbo:content> <![CDATA[ ... ]]> </turbo:content>
where
name
is the goal ID.id
is the tag number.turbo-goal-id
— ID to assign to the Turbo page content
-
Add the ID to the content you want to track statistics for, as the
data-goals
attribute value. You can specify multiple comma-separated values, i.e., you can bind multiple goals to a single element on a Turbo page.<turbo:content> <![CDATA[ <p><a href="http://example.com/" data-goals="goal-link,goal-link2">Text</a></p> ]]> </turbo:content>
-
Add the
turbo:goal
element to an RSS feed:... <turbo:goal type="yandex" turbo-goal-id="goal-link" name="TARGET" id="12345" /> <turbo:content> <![CDATA[ ... ]]> </turbo:content>
where
name
is the goal ID.id
is the tag number.turbo-goal-id
— ID to assign to the Turbo page content
-
Add the ID to the content you want to track statistics for, as the
data-goals
attribute value. You can specify multiple comma-separated values, i.e., you can bind multiple goals to a single element on a Turbo page.<turbo:content> <![CDATA[ <p><a href="http://example.com/" data-goals="goal-link,goal-link2">Text</a></p> ]]> </turbo:content>
-
In Yandex Metrica, use the left menu to go to the Goals page and click Add goal.
-
In the Name field, enter a name for the goal to create.
-
Choose the JavaScript event goal type.
-
Specify the desired condition and goal identifier. Below the identifier field, the Goal code for site line will appear. Copy the code. You will need it to configure the reachGoal method on your site.
Examples of using thereachGoal
method on site pages:Clicking a buttonFilling in a formSending revenue by goal... <form action=""> ... <input type="button" onclick="ym(XXXXXX, 'reachGoal', 'TARGET_NAME'); return true;" value="Order" /> </form> ...
... <form action="" method="get" onsubmit="ym(XXXXXX, 'reachGoal', 'TARGET_NAME'); return true;"> ... </form> ...
... <form action=""> ... <input type="button" onclick="ym(XXXXXX, 'reachGoal', 'TARGET_NAME', {order_price: '1000.35', currency: 'RUB'}); return true;" value="Order"/> </form> ...
How to send revenue data using an attribute selector
To transfer revenue as
order_price
from all pages of the site where it is set by an attribute selector (for example,class
orid
), pass the selector name along with the revenue data to Yandex Metrica.-
Find the fragment in your site code where a selector of this type is set. Example:
<div class="ORDER">Order amount: <div class="PRICE">110</div> RUB</div>
-
Add the selector name to the code of the element that will send the revenue by goal to Yandex Metrica. Example:
<input type="button" onclick="ym(XXXXXX, 'reachGoal', 'BUY', {order_price: document.querySelector('.PRICE')?.textContent}); return true;" value="Order" />
XXXXXX
— Your tag number.TARGET_NAME
— Goal ID.order_price
— Revenue by goal. You can specify revenue in a currency or in conventional units.currency
— Currency of the revenue by goal. Yandex Metrica recognizes a three-letter ISO 4217 currency code.
-
-
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.
Data transmission to Yandex Metrica will start after the robot crawls the RSS feed and detects changes.
The created goal can be used in most Yandex Metrica reports. You can also track conversions by goal using the Conversions report.
Useful links |
Online training |