How to create and install a tag

Creating a tag

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

  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 the same tag.
  • You want to get notifications about site availability checks.

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

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.

Training video. Installing a tag on a site

Watch the video
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 , 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.

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 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.
Note. Put the noscript element and contents in the body element.

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

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

If you were unable to independently check the tag, follow the recommendations below.

This might happen for the following reasons:

  • The tag is installed incorrectly. For example, the CMS modified the code snippet. Reinstall the tag or contact the support service for your CMS.
  • Broken scripts are preventing the Yandex.Metrica tag from working on the site. You can check this in the browser console.

This means that information is being transmitted to Yandex.Metrica. However, the data might not be shown in reports for any of the following reasons:
  • Data is sent to a tag with a different number.
  • The Filters tab in the tag settings has overly strict filters defined. Remove unneeded filters.
  • The Filters tab in the tag settings has the Don't count my sessions filter enabled. This means that the tag doesn't register your own sessions. Try accessing the site with your browser in “incognito” mode.