---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://yandex.com/support/metrica/en/code/install-counter-fb.md
  - https://yandex.com/support/metrica/es/code/install-counter-fb.md
  - https://yandex.com/support/metrica/pt/code/install-counter-fb.md
  - https://yandex.com/support/metrica/ru/code/install-counter-fb.md
  - https://yandex.com/support/metrica/tr/code/install-counter-fb.md
  - https://yandex.com/support/metrica/zh/code/install-counter-fb.md
title: Installing and configuring a tag in Facebook Instant Articles
description: How to install and configure a tag in Facebook Instant Articles.
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/support/metrica/en/llms.txt


# Installing and configuring a tag in Facebook Instant Articles

You can install your Yandex Metrica tag in [Facebook Instant Articles](https://developers.facebook.com/docs/instant-articles)[*](*prohibited-service).

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 {#integration}


{% note alert %}

Content analytics data cannot be collected from Facebook[*](*prohibited-service) Instant Articles.

{% endnote %}


Add the following code to the `body` element in the instant article:

```xml
...
<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:

```xml
...
<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](https://developers.facebook.com/docs/instant-articles/analytics?#analytics-services)[*](*prohibited-service).


## Transmitting session parameters {#params}

1. Create the `yaParams` JavaScript object:
    ```javascript
    ...
    var yaParams = {
      title: "Article title",
      referrer: "Article referrer"
    }
    ...
    ```
    
1. Send parameters for tag initialization:
    
    ```javascript
    ...
    ym([XXXXXX](*counter-number), 'init', {params: window.yaParams||{}});
    ...
    ```
    
    Facebook[*](*prohibited-service) provides [a specific set of data](https://developers.facebook.com/docs/instant-articles/analytics#analytics-services) about instant articles that can be used as session parameters. You can get this data from the `ia_document` JavaScript object.
    
## Transmitting user parameters {#user-params}

1. Send pageview data using the [`hit`](https://yandex.com/support/metrica/en/objects/hit.md) method after tag initialization:

    ```javascript
    ...
    ym([XXXXXX](*counter-number), 'init', {
      defer: true
    });
    ym([XXXXXX](*counter-number), 'hit', ia_document.shareURL, {
      referer: ia_document.referrer,
      title: ia_document.title
    });
    ...
    ```
    
1. Send user parameters by calling the [`UserParams`](https://yandex.com/support/metrica/en/objects/user-params.md) function:
    ```javascript
    ...
    ym([XXXXXX](*counter-number), 'userParams', { user_key: "user_value"});
    ...
    ```
    


## Example of tag integration {#example}

```javascript
<body>
  ...
  <figure class="op-tracker">
    <iframe>
      
      <noscript><div><img src="https://mc.yandex.ru/watch/[XXXXXX](*counter-number)" style="position:absolute; left:-9999px;" alt=""/></div></noscript>
    </iframe>
  </figure>
  ...
</body>
```

`XXXXXXXX` — Your tag number.



<!-- source: en/_includes/buttons/chat-button.md -->
[Chat with us](https://yandex.com/chat/#/user/036e6a02-3620-9cdc-4c5e-a34667a7379e?utm_source=spravka){.button}

<!-- source: en/_includes/styles/href-to-button.md -->

<!-- endsource: en/_includes/styles/href-to-button.md -->
<!-- endsource: en/_includes/buttons/chat-button.md -->

<!-- source: en/_includes/code/texing-button.md -->
<div class="cut-button">

{% cut "Write an email" %}

<!-- source: en/_includes/popup/id-qanda/check1.md -->
If you were unable to [independently check the tag](https://yandex.com/support/metrica/en/general/check-counter.md), follow the recommendations below.
<!-- endsource: en/_includes/popup/id-qanda/check1.md -->

{% list tabs radio %}

- Data is not sent to the console

  {% include [qanda-check2-2](../_includes/popup/id-qanda/check2-2.md) %}

  {% cut "The recommendations did not help" %}


  <div style="padding: 15px;
         margin: 10px 0;
         background: #FFFFFF;
         border-radius: 10px;
         border: 1px solid var(--g-color-line-generic);">
    <iframe style="background: #FFFFFF;"
            height="700"
            width="100%"
            frameborder="0"
            src="https://forms.yandex.com/surveys/1706/?&theme=Dannye v konsoli ne otpravlyayutsya&iframe=1&lang=en">
    </iframe>
  </div>

  {% endcut %}

- There is data in the console, but the reports do not appear

  <!-- source: en/_includes/popup/id-qanda/check2-3.md -->
  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:
  <!-- endsource: en/_includes/popup/id-qanda/check2-3.md -->

  <!-- source: en/_includes/popup/id-qanda/check2-4.md -->
  - 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.
  <!-- endsource: en/_includes/popup/id-qanda/check2-4.md --> 

  {% cut "The recommendations did not help" %}


  <div style="padding: 15px;
           margin: 10px 0;
           background: #FFFFFF;
           border-radius: 10px;
           border: 1px solid var(--g-color-line-generic);">
    <iframe style="background: #FFFFFF;"
              height="700"
              width="100%"
              frameborder="0"
              src="https://forms.yandex.com/surveys/1706/?&theme=Dannye v konsoli est, no otchety ne otobrazhayutsya&iframe=1&lang=en">
    </iframe>
  </div>

  {% endcut %}

{% endlist %}

{% endcut %}

</div>

<!-- source: en/_includes/styles/cut-button.md -->

<!-- endsource: en/_includes/styles/cut-button.md -->
<!-- endsource: en/_includes/code/texing-button.md -->

<!-- source: en/_includes/footer-links.md -->
- - -

<div class="borderless-table">

#|
||
Useful links

- [Demo tag](https://metrica.yandex.com/r/dashboard?)
- [Add a tag](https://metrica.yandex.com/add/)
- [Free tag setup](https://yandex.com/promo/freeservice/metrica?utm_source=help_metrica_en&utm_medium=cpc&utm_campaign=1)
- [Yandex Metrica API](https://tech.yandex.com/metrika/)
- [Suggest your idea](https://yandex.com/support/metrica/troubleshooting/idea.html)
- [Discuss in Telegram](https://t.me/yandexmetrika)
|
Online training

- [Get a Yandex Metrica certificate](https://yandex.ru/adv/expert/exam/metrika/?utm_source=metrika_help&utm_medium=web&utm_campaign=static&utm_content=useful_links)


- [Take a training course](https://yandex.com/adv/edu/online/metrika?utm_source=metrika_help&utm_medium=web&utm_campaign=static&utm_content=useful_links)

||
|#

</div>

<!-- source: en/_includes/styles/table-style.md -->

<!-- endsource: en/_includes/styles/table-style.md -->
<!-- endsource: en/_includes/footer-links.md -->

<!-- source: en/_includes/styles/cut-button.md -->

<!-- endsource: en/_includes/styles/cut-button.md -->

[*prohibited-service]: Banned in Russia.

[*counter-number]: XXXXXX is your counter number.
{% included (../_includes/popup/id-qanda/check2-2.md) %}
   This might happen for the following reasons:
   - The tag is installed incorrectly. For example, the CMS modified the tag code. 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.


{% endincluded %}