How to create and install a tag

Creating a tag

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

  1. 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. In addition, URL request parameters will be ignored (the part of the URL after the “?” symbol).

      More information about the URL structure

      http://<host>/<path>/<page>?<params>

      • <host> — Site domain.
      • <path> — The path, which can have a hierarchical structure. The structure is indicated using slashes (“/”).
      • <page> — The page name.
      • <params> — The parameters section, which is separated from the <path> section using the “?” symbol.
  2. Accept the terms of use.
  3. Click Create a tag.

* Required information.

You can also:

Enable session recording, heat maps, and form analysis.
To do this, set the option Session Replay, scroll map, form analysis to On. This option also enables the click map and link map.

Learn more about Session Replay

Learn more about Form Analysis

Add additional site addresses

This can be useful if:

  • The same site with the same installed tag responds from different addresses.
  • You want to get statistics for multiple sites using a single tag.

Click-throughs 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. In addition, URL request parameters will be 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:

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

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

Enable the option “Don't save full IP addresses of site users”

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

To enable the option, open the Additional data processing conditions section.

Confirm your acceptance of the Yandex.Metrica data processing agreement

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

Tip. To install the tag, we recommend contacting the employee who is responsible for website support.
Installing a tag on a site with a CMS
  1. In the Yandex.Metrica interface, go to the Settings section (on the Code snippet tab) and click Copy.
  2. Add the copied code to the file that generates the header for all the site's pages.

Official Yandex.Metrica plugins are available for the most popular CMS programs, which can install the code snippet automatically. 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.

Installing a tag on a site without a CMS
  1. In the Yandex.Metrica interface, go to the Settings section (on the Code snippet tab) and click Copy.
  2. If this is not a large site and all the pages are separate files created manually, add the saved code to the HTML code of every page on the site. We recommend inserting it as close to the top of the page as possible — the accuracy and completeness of data calculation depends on this.

*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. Data starts being collected immediately. A few minutes after you have installed the code, the My tags page shows the verification status for whether the tag is correctly installed.

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.

Checking the tag

To check whether the code snippet was installed correctly:
  1. Append the ym_debug parameter with the value 1 to the page URL in the browser's address bar, and reload the page.
    http://example.com/?_ym_debug=1
  2. Open the browser console with the keyboard shortcut Ctrl + Shift + J ( + + J for Apple OS). If the snippet is installed correctly, the console will show the tag ID and the data that is sent by the snippet.

Information might be missing in the console for the following reasons:

  • The tag is not installed on the site.
  • The tag is installed incorrectly.
  • Other scripts are blocking the Yandex.Metrica tag on the site. You can check this in the browser console.

    To fix errors, contact the employee who is responsible for website support.

  • The tag is blocked by the Adblock Plus extension.
  • The mc.yandex.ru domain is blocked in the hosts file on your OS.

Collecting statistics on different domains and subdomains

Yandex.Metrica provides several ways to do this:

MethodAdvantagesSpecial considerations
A single tag for all addresses
Provides overall statistics for all the sites. You can:
  • Set up multi-step goals with steps that are related to different sites.
  • View Session Replay recordings, click maps, link maps, and scroll maps.

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:
  • Get data on traffic sources.
  • Configure goals.
  • View Session Replay recordings, click maps, link maps, and scroll maps.
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.
Tip. To get the most information possible about the sites, use both of these methods together.
Single tag
  1. 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
  2. Add the code snippet to the HTML code of the pages of these sites.
Different tags
  1. In the Yandex.Metrica interface, create multiple tags (one for each address).
  2. Add the tags to the HTML code of the pages of these sites.
  3. To view statistics, set up a report for a group of tags in the Yandex.Metrica interface.