Facebook Pixel conversion tracking for AMP

NOTE: This feature is only available for some of our subscriptions. If that is the case, you will see an upgrade prompt when attempting to access it. More information about our currently available subscriptions can be found here: https://instapage.com/plans 

An AMP (Accelerated Mobile Page) is designed for campaigns targeted primarily at mobile users, which helps you keep your visitors’ attention with loading times of under 1 second. AMP pages are generated differently compared to standard pages, which means the code used on them has to be adapted specifically for AMP. In this article, you can find the code you need to add to your AMP in order to track conversions inside your Facebook account.

NOTE: If you want to implement Facebook Pixel conversion tracking on an AMP, do not use our native Facebook Pixel integration at the same time. It is enough to use the code in this article. If you use both, the page views will be tracked twice.

Any of the codes below will need to be placed in HTML/CSS > Body. AMP validation will return errors if the codes are placed anywhere else.

1. Use the following code snippet for tracking only form submissions:

You will need to replace the Facebook Pixel ID on the 8th line and then customize the “eventName” value to match your event name on Facebook.

2. Use the following code snippet for tracking only a button click (it works only for one specific button; if you want to track more than one button, the code needs to be edited to contain multiple “buttonClick” key - value pairs):

You will need to replace the Facebook Pixel ID on the 8th line and add the element ID of the button you want to track on the "selector" line, and then customize the “eventName” values to match your event names in Facebook.

To get the element ID of a button, go to the preview mode or the live page and right-click the button, select Inspect, and copy the ID as shown in the gif below. The ID will be in the w-A-1 format.

Screen_Capture_on_2023-03-13_at_13-27-05.gif

3. Use the following code for tracking a form submission and a button click on the same page:

For this use case, on a standard landing page, you would add the code snippets above separately, but since AMPs have a different structure, you will need the code from below instead.

You will need to replace the Facebook Pixel ID on the 8th line and add the element ID of the button you want to track on the "selector" line, and then customize the “eventName” values to match your event names on Facebook.