how to add Facebook's pixel into Google's AMP?

Viewed 8632

For the time being, it appears that no one at Facebook nor Google have added Facebook tracking pixel into amp-analytics yet.

Does anybody here knows how to do it ? sample code or github is preferred.

thank you very much

2 Answers

It seems support was added on June 6, 2017. You can do:

<!-- Facebook Pixel Analytics tracking -->
<amp-analytics type="facebookpixel" id="facebook-pixel">
    <script type="application/json">
    {
        "vars": {
            "pixelId": "YOUR_ID"
        },
        "triggers": {
            "trackPageview": {
                "on": "visible",
                "request": "pageview"
            }
        }
    }
    </script>
</amp-analytics>
<!-- End Facebook Pixel Analytics example -->

The documentation can be found here.

Related