How to create and install a tag
Creating a tag
Training video. Creating a code snippet. Watch the video |
Training video. Creating a code snippet. Watch the video |
Step 1. Log in to Yandex
If you don't have an account, register.
Step 2. Add a tag in Yandex Metrica
On the page with the list of tags, add a tag. The tag setup page opens .
Step 3. Enter the main tag settings
Fill in the information:
- Tag name. The specified name is shown on the My tags page and in the upper menu for switching between tags. If it is not set, Website address is used instead.
Site URL.* The main domain of the site. This information is required. Don't include the prefix of the schema or protocol (
http://
,https://
).In this field, you can enter the site's path in the URL structure. For example, example.com/category/. However, don't specify the URL for a specific file or page section (using the “#” symbol), or you will get an error. Additionally, parameters passed in the URL are ignored (the part of the URL after the “?” symbol).
- <host> — Site domain.
- <path> — A path that can have a hierarchical structure. The structure is indicated using slashes “/”.
- <params> — The section of parameters that is separated from the path by a “?”.
- <fragment> — A fragment of the content on a page that is separated from the parameters and path with a “#”.
More information about the URL structurehttps://<host>/<path>?<params>#<fragment>
- Accept the Terms of use.
- Click Create a tag.
* Required information.
You can also:
- The same site with the same installed tag responds from different addresses.
- You want to get statistics for multiple sites using the same tag.
- Someone initialized a tag with your number on their own site (probably by mistake).
- Your site's pages were being viewed via a proxy service.
- There is an almost exact copy of your pages on other domains. When copying content, the code snippet was also copied.
To do this, enable the option Automatically track clicks to phone number, email, and form submission in the tag settings. If you created a tag recently, this option is already enabled.
This can be useful if:
Clicks between all of the set addresses are interpreted as internal clicks.
In this field, you can enter the site's path in the URL structure. For example, example.com/category/. However, don't specify the URL for a specific file or page section (using the “#” symbol), or you will get an error. Additionally, parameters passed in the URL are ignored (the part of the URL after the “?” symbol).
If reports show data on page views that don't belong to your site addresses and you don't need this data, select Receive data only from specified addresses.
This situation can arise in the following cases:
The Including sub-domains option lets you include subdomains of the main site and additional sites for filtration (subdomain.example.com
, other.subdomain.example.com
, ...).
Yandex Metrica can send you news and recommendations about working with tags. To receive notifications, enter the email address in the Notification email section. Learn more about setting up notifications
Yandex Metrica normally stores the entire depersonalized IP address of the user. If this option is enabled, the system registers an incomplete address. For example, 192.0.2.2 changes to 192.0.2.0. This means that location detection will not be as precise. Learn more
To enable the option, open the Additional data processing conditions section.
This is necessary if your company is registered in the EU or Switzerland, or if you are required to comply with the General Data Protection Regulation (GDPR) for other reasons. Learn more
To accept the agreement, open the Additional data processing conditions section.
Step 4. Specify additional tag settings
Under Additional settings, turn on the options you need.
Installing a tag
Training video. Installing a tag on a site Watch the video |
Training video. Installing a tag on a site Watch the video |
- In Yandex Metrica, go to Settings and click Copy on the Tag tab.
- Add the copied code to the file that generates the header for all the site's pages.
- In Yandex Metrica, go to Settings and click Copy on the Tag tab.
- If all the pages on your site are manually-created separate files, add the tag code to the HTML for all website pages. We recommend placing it inside the head or body elements and as close to the top of the page as possible — the completeness and correctness of data calculations depend on this.
Official Yandex Metrica plugins , which can install code snippets automatically, are available for the most popular CMS programs. In most cases, all you need to do is install the plugin and log in.
If you use multiple CMSs on the same website (for instance, you have one for the site content and another that runs a forum), you need to add the code snippet to all of them.
*CMS is a Content Management System, a program for managing website content. A CMS is used for uploading and removing texts, images, or videos on a website without needing any programming skills.
After installation, the tag will be available on the My tags page. The tag immediately starts collecting data.
You can also install a tag using a tag management system, and you can install multiple tags at once.
You can edit the code snippet (for example, enable or disable collecting certain data). However, you will need to replace the code on all the site's pages. After a tag is edited, all previously accumulated data is not recalculated.
Collecting statistics on different domains and subdomains
Yandex Metrica provides several ways to do this:
Method | Advantages | Special considerations |
---|---|---|
A single tag for all addresses | Provides overall statistics for all the sites. You can:
| When users move between different sites, it is registered in a single session. |
Different tags for each address | Provides separate statistics for each site. You can:
| To view cumulative statistics for all the sites, you need to set up a report for a group of tags. This does not allow you to track goals or view Session Replay recordings and data from click maps, link maps, and scroll maps. |
Method | Advantages | Special considerations |
---|---|---|
A single tag for all addresses | Provides overall statistics for all the sites. You can:
| When users move between different sites, it is registered in a single session. |
Different tags for each address | Provides separate statistics for each site. You can:
| To view cumulative statistics for all the sites, you need to set up a report for a group of tags. This does not allow you to track goals or view Session Replay recordings and data from click maps, link maps, and scroll maps. |
In the Yandex Metrica interface, go to Settings (the Tag tab) and enter all the addresses that you want to track in these fields:
- Site URL
- Additional addresses
- Add the code snippet to the HTML code of the pages of these sites.
- In the Yandex Metrica interface, create multiple tags (one for each address).
- Add the tags to the HTML code of the pages of these sites.
- To view statistics, set up a report for a group of tags in the Yandex Metrica interface.