Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 266
diego Avatar asked Aug 02 '17 08:08

diego


People also ask

Can I add Facebook pixel to Google sites?

Hey just put my pixel on my google site and it worked, just use the embed feature on the side tool bar, add the pixel URL you got from Facebook and make the box really small, you can see the pixel is working at the top left of the picture I posted.

How do I add Google analytics to my amp?

Set the type attribute for <amp-analytics> to "gtag" (to enable gtag. js support) and the data-credentials attribute to "include" (to enable cookies.) AMP does not allow any JavaScript beyond its own approved libraries, so configuration is instead performed with JSON.

How do I add a pixel to a Facebook link?

Go to the Pixels tab. Click Manually add pixel code to website. Copy the code and paste it in Linkly, under Retargeting Pixels -> Head Tags. You'll want to add a custom tracking event to Facebook, so you'll know people came from this link.


1 Answers

This should work

<amp-pixel src="https://www.facebook.com/tr?id=YOUR_ID&ev=PageView&noscript=1" 
    layout="nodisplay"></amp-pixel>

You will need to change YOUR_ID to the ID you can find in Facebook's tracking code.

I created this by adopting the noscript src from their sample script for use in amp-pixel. More advanced usages would be possible, but ideally Facebook would provide the respective documentation.

like image 109
Malte Ubl Avatar answered Sep 30 '22 15:09

Malte Ubl