New snippet in the tag settings

In the tag settings, you may have noticed a new code snippet to install on your site. It is optimized for the latest web technologies and provides support for the new features we plan to add to Yandex.Metrica.


How is the new snippet better?

It allows more data to be collected when a site — and the Yandex.Metrica snippet — is loading on a slow connection. Another case is when you transmit session parameters or user parameters to Yandex.Metrica immediately after a site starts loading, when the snippet might not have finished loading: in this case, the new snippet will collect all transmitted parameters regardless of when it loads.


Do I have to install the new code snippet on my site?

The old snippet will continue to work, but the new snippet will allow you to use all the new Yandex.Metrica features. For this reason, we recommend that you install the new snippet on all pages of your site, replacing the old snippet.

The new snippet only supports Session Replay 2.0. If you used the previous version of  Session Replay and installed the new snippet on your site, sessions will automatically be recorded using Session Replay 2.0.


I use the JavaScript API. Do I need to update my methods?

Not necessarily — the old methods of tag initialization are compatible with the new version. But the advantages of the new snippet will only be available with the updated set of methods.

If you have questions about the new code snippet, ask in the comments, or contact our support service.