Examples of sending session parameters
Transmitting traffic indicators
Let’s say that your site contains various articles and you want to know which authors bring the biggest audience to your site. To do this, in the parameters, you can send data about viewing a specific author:
<script type="text/javascript">
window.yaParams = { "Author": 123 };
ym(XXXXXX, 'params', window.yaParams||{});
</script>
Or, for example, you may want to know which category of articles users view the most. In the parameters, you can transmit data about a category’s viewing:
<script type="text/javascript">
window.yaParams = { "Category": 123 };
ym(XXXXXX, 'params', window.yaParams||{});
</script>
Transmitting a hierarchical data structure
For instance, we need to transmit data and show it in a report in a tree view.
<script type="text/javascript">
window.yaParams = {
"level1":{"level2":["level3_1","level3_2"]}}
...
ym(XXXXXX, 'params', window.yaParams||{});
</script>
AB testing
Let’s say we need to conduct an experiment to determine how the color of the Buy button affects the conversion rate for a View basket goal.
If the user is shown a red button, we use the following parameter:
window.yaParams = {ab_test: "red"};
If the user is shown a green button, we use the following parameter:
window.yaParams = {ab_test: "green"};
This parameter is transmitted in any convenient way. For example, it can be passed when initializing the tag on item pages or using the reachGoal method that is called when the Buy button is clicked.
After that, we'll be able to use the ab_test
parameter value to select the corresponding data in the Yandex Metrica interface.
Report on authorized and unauthorized users
Use the following code sample to analyze differences in the behavior of registered and non-registered site users:
<script type="text/javascript">
window.yaParams = {'Username': '[% paste the username from the site template engine %]' || 'Guest'};
ym(XXXXXX, 'params', window.yaParams||{});
</script>
where XXXXXX is the tag ID.
Useful links |
Online training |