Installing and configuring a tag in Facebook Instant Articles
You can install your Yandex Metrica tag in Facebook Instant Articles*.
Due to the way Instant Articles are implemented, the JavaScript tag code is isolated from other HTML elements. This means that the following features of Yandex Metrica are available:
- Session Replay
- Click map, link map, and scroll map
- Form analysis
- E-commerce data
You can use special HTML elements to add the Yandex Metrica code snippet to an instant article.
Installing a tag
Alert
Content analytics data cannot be collected from Facebook* Instant Articles.
Add the following code to the body
element in the instant article:
...
<figure class="op-tracker">
<iframe>
<!-- Tag code -->
</iframe>
</figure>
...
The tag registers sessions for the page that is specified in the head
element as canonical:
...
<head>
<meta charset="utf-8">
<link rel="canonical" href="http://example.com/page.html">
<meta property="op:markup_version" content="v1.0">
</head>
...
To check that the tag is working correctly, use the endpoint from Facebook*.
Transmitting session parameters
-
Create the
yaParams
JavaScript object:... var yaParams = { title: "Article title", referrer: "Article referrer" } ...
-
Send parameters for tag initialization:
... ym(XXXXXX, 'init', {params: window.yaParams||{}}); ...
Facebook* provides a specific set of data about instant articles that can be used as session parameters. You can get this data from the
ia_document
JavaScript object.
Transmitting user parameters
-
Send pageview data using the
hit
method after tag initialization:... ym(XXXXXX, 'init', { defer: true }); ym(XXXXXX, 'hit', ia_document.shareURL, { referer: ia_document.referrer, title: ia_document.title }); ...
-
Send user parameters by calling the
UserParams
function:... ym(XXXXXX, 'userParams', { user_key: "user_value"}); ...
Example of tag integration
<body>
...
<figure class="op-tracker">
<iframe>
<script type="text/javascript"></script>
<noscript><div><img src="https://mc.yandex.ru/watch/XXXXXX" style="position:absolute; left:-9999px;" alt=""/></div></noscript>
</iframe>
</figure>
...
</body>
XXXXXX
— Your tag number.
Useful links |
Online training |
Banned in Russia.
XXXXXX is your counter number.