Where to place the Yandex metric counter code. Yandex.Metrica - what kind of beast and how to tame it

Yandex.Metrica is a free web analytics service that collects data on traffic and user behavior in reports and helps to improve the effectiveness of advertising. In this article, we will analyze how to get started with Yandex.Metrica and how to install its code on a website.

The first thing to start working with Yandex Metrica is to install this system on your website. Here novice users may face a problem: how to install the Yandex Metrica code on the site? What if this site is made on WordPress?

Generating Counter Code

The added counter in the Yandex Metrics service looks like this:

How to create a Yandex Metrica counter code

Installing counter code on WordPress site

If you are using CMS WordPress, then here are two methods for adding a Yandex Metrica counter code to WordPress.

Add counter code to editor


The counter code is installed on the site!

Install Yandex Metrics counter on WordPress plugin

The WordPress repository has a plugin to install the counter code. It is called Yandex Metrica. However, you need to search for it by requesting Yandex.Metrika.

After installing and activating the plugin, go to its settings. Insert the counter code into the only window. After saving the changes, the plugin starts its work.

To check if the code was set correctly, return to the counters page. After refreshing the counter you should see a green icon.

Check site counter operation

As you can see install Metric on wordpress not difficult at all. Repeat these steps and you should be good to go.

Every day, thousands of new sites of various directions and topics appear on the Internet, but the ultimate goal of each of them is to inform the audience about goods, services, companies, world news and much more.

Yandex.Metrica is a free tool for assessing audience behavior on the site and analyzing traffic sources, which demonstrates information in colorful reports, graphs, diagrams and clearly shows everything that users have done on the site. Yes, Yandex.Metrica contains video recordings of user visits to your site! They allow you to evaluate not only on which areas of the page the user spent the most time, where they clicked and which page they went to next, but also to evaluate how the site was displayed on the device of this particular user.

Basic data that contains Yandex.Metrica reports

  • Traffic sources - where the audience came from: search, advertising, social network, mailing, etc.
  • Lecture hall - demographic, geographic data, indicators of engagement and loyalty.
  • Conversion report - how many purchases, form submissions on the site, clicks, views made by site visitors, by what audience and from what source.
  • Technologies- data on user devices (PCs, smartphones, tablets), OS, screen resolution from which the visit was made.
  • Monitoring data - load on the site, page load time, site health check results.
  • E-commerce data (for online stores) - a summary of orders, purchase amounts, popular products and much more.

Otherwise, the owners of sites that do not have web analytics counters will not be able to get information about where the audience comes to them from, in what quantity, what quality, and, importantly, they will not be able to determine which channel is the most cost effective.

Registration and setup of the counter

Installing and configuring the Yandex.Metrica counter does not take much time. Below we will take a step by step how to register, install and configure a web analytics system for a website.

Next, you need to create a counter. To do this, click on the yellow button "Add counter" and go to the registration page for a new counter.

63.64 KB

In field Website address enter the site domain without http / https. For example, site.ru or site.ru/category/ - if you need to set a separate counter for a section or page of a site.

You can also specify additional site addresses if you plan to create a single counter for several sites, or set the "Accept data only from specified addresses" setting so that the reports will display information only on your site:
25.53 KB

We choose the time zone in accordance with the location of the company - for the accuracy of the data in the reports on the date and time of visits.

Next, we activate the collection of information for reports on the webviewer, scrolling maps, clicks and form analytics - these reports contain detailed records of visitors' actions on the site: mouse movements, page scrolling and clicks.

Put a tick in the "I accept the terms of the user agreement" checkbox and click on the "Create counter" button in the lower left corner.

After that, a screen appears with additional settings and counter code, which must be installed on all pages of your site (or on a specific section if you create a separate counter for a specific section).

Additional counter settings

When you click on the subheading "Additional settings", a list appears in which you can set additional options:

  • Hash tracking in the browser address bar.This option is applicable for AJAX sites. This technology is rarely used and in most cases the checkbox remains empty.
  • Asynchronous code.This setting is active by default and is responsible for ensuring that the counter code does not affect the page loading speed of your site and does not block it.

    The asynchronous code looks like this:

    With the option disabled, the code will look like this:

    The "Asynchronous code" option is disabled in the code

  • For XML sites there are separate requirements for the counter code, so for such sites you need to check the box in the corresponding checkbox, which will remove tags from the counter code
  • One line»Is responsible for the type of the counter code. With this option enabled, the code will look like this:

    One Line setting shortens the look of the code
  • Prohibition of sending for indexing of site pages... This setting is necessary if you do not want your site pages to be in the index of search engines. The setting is similar to prohibiting indexing through the robots.txt file. Useful when the site is not yet ready for publication and contains test or unfilled sections. If you turn off this setting in the future, you will need to copy the new counter code from the field on this page and update the code on the site.
  • Informer... If you enable this setting, an icon with information about your site traffic will be displayed in the footer (lower part) of the site. In the additional settings of the informer, you can select the size of the icon, color and type of data that will be displayed. The data will be available to everyone who visits your site and scrolls to the footer.

  • Alternative CDN... This option allows you to correctly take into account visits from regions where access to Yandex.Metrica is restricted. The option can reduce the download speed of the counter code, but even with the "Alternative CDN" enabled, the counter code can send a preliminary request to mc.yandex.ru to save traffic.
  • Submitting to Metrica e-commerce data... An important setting if you have an online store. The option allows you to connect Ecommerce through the interface and collect data on the number of orders, the amount of purchases, etc. If this option is enabled, by default the JavaScript array is named dataLayer. You can change it in the field Data container name... Read more about connecting an online store to Yandex.Metrica on the Yandex.Help page.
  • Currency. The setting is responsible for the currency in which data on the order value and average bill will be displayed in e-commerce reports. Choose the option that is used on your website - if the cost of goods is presented in rubles, choose the Russian ruble.
  • Visit timeout in minutes... The amount of time a user has been inactive on your site after which the visit is considered complete. The default timeout is 30 minutes. But if you post long videos on the site that users will watch without performing any actions with the mouse, then for the correct collection of information, it is recommended to increase the timeout (how much should be based on the duration of the video materials on your site). The maximum time that can be set is 360 minutes.

This completes the additional settings. In most cases, in this section, only the Asynchronous code option will be active and, if the counter is configured for an online store, the last item responsible for sending e-commerce data.

An important point! If you have made any changes to the "Additional settings" after installing the counter on the site, you need to update the code on the site page, because each setting adds or removes lines and characters in the counter code.

Therefore, the counter code on the settings page is displayed below, under all settings. It is located in a black container.

Click on the yellow button Copy code and for convenience save it in a txt text file.

On the settings page, scroll down and click on the "Start using" button.

But before the reports start collecting data, the counter code must be installed on your site.

Installing the code on the site

Several installation options are provided:

  • add to HTML code,
  • install via CMS widgets and website builders,
  • through tag management systems.

Html code

Open the template code on the site and add a counter within the tags or as close to the top of the page as possible: this way it will load earlier and be able to send browsing data to Metrica, even if the visitor closes the page almost immediately.

If the site uses several templates, add the counter code to each of them.

Then we open the site in a browser and check that the code is present on the pages. To do this, open the site code using the Ctrl + U key combination, scroll the page and look for the counter code with our eyes. Or start the search bar on the page with the key combination Ctrl + F, enter Metrika in Latin, press Enter and see the result - if the counter was added successfully, you will see it in the code:

CMS widgets and website builders

Option 1. For some systems, there are ready-made plugins. Usually in the plugin it is enough to specify only your counter number, in our case - 49906027. It can be found next to the name in the general list of counters.

Option 2. If there is no plugin, the counter code must be inserted into the field for an arbitrary html block. Read more about installing the counter code via CMS or website builder in Help.

Tag Management Systems

Google Tag Manager: create a new tag with the Custom HTML template, insert the Metrica counter code into it. Don't forget to add the All Pages trigger so that the counter code will load from any page on the site.

Other tag management systems provide a similar field for inserting arbitrary html code. And in Tealium, integrated with Metrica, it is enough to indicate the number of your meter in the appropriate field.

After you have successfully installed the code on your site, in the list of Yandex.Metrica counters next to the name of your counter the icon will change from yellow to green.

Hello, friends. You already have a blog, you fill it with materials and want to know how many people read you? Then it's time to install on the site yandex Metrics counter and below I will show you how to do it. Go!

Installing Yandex Metrics

We go to the page metrika.yandex.ru. Press the button "Add counter".

On the next page, enter the name of the counter and the domain of the site and click "Create". Then go to the "Counter Code" tab.

I advise you to check the following boxes:

  • Webvisor - allows you to monitor user behavior. A useful feature!
  • Asynchronous code - the counter will not slow down the website loading speed. We put;
  • One line - will reduce the size, but make the code unreadable. For an amateur;
  • Informer - usually placed in the footer. Shows statistics to all visitors to your site. I don’t bet.

On the "Webvisor" tab:

  • Recording pages when viewed by a visitor - disabled (Needed for online stores);
  • Robot writing pages - turned off;
  • Loading pages into the player is not important (I have it on behalf of an anonymous user).

We will analyze the goals and filters later, the main thing for us now is to understand how to install Yandex Metrica.

After the above settings, click the button on the right "Save" and return to the "Counter Code" tab. We press the button "Copy to clipboard" and paste this code into the footer of our blog. If you don't know how, read on.

Where to insert the Metrica code?

I'll show you 2 ways to add code.

Via FTP

For me this is the easiest way. At the root of your site, go to the theme folder, most often it is located at "/ wp-content / themes / theme_name" and find the "footer.php" file there. Open it and paste the counter code before the closing tag and don't forget to save.

Through the WordPress admin area

The second method is suitable if you do not have FTP access - install the counter through the WordPress admin panel. To do this, go to the "Appearance - Editor" section in the admin panel, find the file "foter.php" (May be called "Footer") in the list on the right and add to the end before the tag counter code.

Now on the page with your counters there is a new one, someone has the first. We go into it and analyze all the statistics of our blog.

In the next tutorial, I'll show you how to set up a Google Analytics counter. On this I say goodbye. Good luck!

If you have already created your site and it is open for indexing by search engines, then soon you will want to receive information about traffic statistics, traffic sources, etc. To do this, you need to install a traffic counter on all pages of the resource. Let's try to figure out how and where to install such counters.

Yandex.Metrica

Creature

To create a Yandex.Metrica counter, follow the link, being logged in under your account, and click the "Add counter" button:

Then you need to fill in the fields "Counter name" and "Site address", select the time zone, accept the terms of the user agreement and click "Create counter":

After that, you will immediately be taken to the counter settings panel, where you can select certain parameters of its operation, for example, enable the webviewer, track the hash (for ajax sites), or install the informer:

As shown in the screenshot, the counter code with all its settings is presented in the field at the very bottom. Now all that remains is to copy the code and place it on the site.

Installation

It is best to install counters on all pages of a resource, so you need to place your code in a common template.

In general, it will look something like this:

In this case, the informer does not have to be placed together with the main counter code, for example, it can be removed to the footer of the page, before the closing tag:

Google Analytics

Creature

Creating a counter starts with registering a new Google Analytics account. To do this, follow the link and click "Register".

Then click "Get Tracking ID" and accept the user agreement:

Immediately after that, you will be taken to a page with a new counter, the code of which must also be placed on all pages of the site.

You can read about the detailed setup of the Google Analytics counter.

Installation

The installed counter looks something like this:

Installation of counters in various CMS

Bitrix

To install counters in Bitrix, you just need to open the general template and paste the code.

To do this, being on any page (provided that one template is used for all pages), you need to expand the administrative panel (or, in another way, the Development Panel), select the "Site Template" tab, the "In Control Panel" sub-tab and click "Edit template":

Then insert the required counters according to the examples given above:

WordPress

When installing counters on WordPress, no problems should arise either.

It is enough to select the "Appearance → Editor" tab in the administration panel, open the header.php file for editing (signed as "Header") and insert the counters:

OpenCart

There is a special field for adding a Google Analytics counter in OpenCart.

You need to go to the "System → Settings" section, in front of your store, select the "Change" action, then select the "Server" tab:

At the bottom of the page, insert the counter code into the "Google Analytics Code" field and save:

You can install the Yandex.Metrica counter and any others in the general template, according to the examples above. To do this, you will have to connect to the site via FTP and find the template files. Typically, the path is something like this: / catalog / view / theme / your_theme / template / common files footer.tpl or header.tpl

Joomla

As with all systems described above, counters are placed directly in template files. But if using FTP access is not very convenient, or there is a fear of doing something wrong, you can place the counters right in the admin panel.

To do this, you need to create an HTML module (tab "Extensions → Module Manager", click "Create" and select "HTML code") and configure it.

So, let's create a new module:

  1. We give it a name
  2. Insert the counter code
  3. Hide the title display
  4. Choosing a position
  5. Bind to all pages
  6. We are happy!

If you use the framework, then most likely it already provides for the possibility of placing counters on all pages (you will have to look carefully in the settings).

Other counters

All other counters, for example Mail.Ru Rating, LiveInternet, etc., are recommended to be inserted before the closing tag... This is primarily necessary so that the code does not interfere with the page loading. If you still want to place the code somewhere else, then you can use asynchronous loading (the "async" attribute for the tag