Affilimate
  • Home
  • Features  
  • Integrations
  • Pricing
  • Demo

Set up AMP tracking

AMP support is currently in beta. Please contact our Support team at support@affilimate.com if you'd like to participate in the beta program, and have a staging version of your website available for testing.

There are a few key changes you'll need to set up on your AMP pages in order to get Affilimate's tracking to collect data on them:

  1. Load the Affilimate snippet inside <amp-script> with your API key attached
  2. Wrap your content inside an <amp-script> element that references the snippet
  3. Set up canonical URL tracking
  4. Test your AMP setup
  5. Apply the same setup to your production server

If you haven't yet, you'll need to make sure that AMP script itself is loaded on your website via:

<script async custom-element="amp-script" src="https://cdn.ampproject.org/v0/amp-script-0.1.js"></script>

Step 1. Loading the Affilimate snippet on AMP pages

Start on your staging server.

Affilimate's standard installation includes two elements: a meta tag and a JavaScript snippet:

<meta name="am-api-token" content="YOUR_TOKEN_HERE">

<script async src="https://snippet.affilimate.io"></script>

On AMP pages, you'll combine those into a single AMP script tag, and you'll directly load our latest script version instead of allowing us to auto-optimize which script we load.

You'll need three values, two of which are placed inside the AMP script tag. For example, if:

  • The Script Version is e893f3356 this will go after ?v=
  • Your API Token is YOUR_TOKEN_HERE this will go after &apiToken=

The AMP script tag would be:

<amp-script src="https://snippet.affilimate.io/affilimate.js?v=e893f3356&apiToken=YOUR_TOKEN_HERE" id="affilimate"></amp-script>

You can find your actual API token by taking it from the content parameter of the meta tag shown in your General Settings.

Then in the <head> of your site, add the final value, known as the Script Hash:

<meta name="amp-script-src" content="sha384-dJzz2a9NrL9ejaoLdhgeoNe9l9J_sjgzy1TgDlM2u39UuneIqFa0DgrbaWdM9jRN"/>

If you already have other externally loaded scripts, simply add the script hash after your current hashes with comma separations.

Important: The Script Hash has will update anytime the Script Version updates. Always update these two parameters together when you're pulling the latest versions from this documentation.

Step 2. Wrap your content inside another amp-script tag

Next, wrap your content inside an amp-script tag to give Affilimate the ability to track and add attribution data to your links.

It's important that your earliest affiliate link on the page be included. For example, if you have affiliate links in your navigation bar, your navigation bar must also be wrapped in the amp-script tag.

Use this tag wrap the content with the following wrapping element.

<amp-script script="affilimate" layout="container">
   <!--- Your website content here --->
</amp-script>

A semi-realistic example of all these values combined could look like:

<head>
   <!-- Script hash -->
   <meta name="amp-script-src" content="sha384-dJzz2a9NrL9ejaoLdhgeoNe9l9J_sjgzy1TgDlM2u39UuneIqFa0DgrbaWdM9jRN"/>
</head>
<body>

  <!-- AMP script -->
  <amp-script src="https://snippet.affilimate.io/affilimate.js?v=e893f3356&apiToken=347h2yh2" id="affilimate"></amp-script>

  <!-- AMP wrapper -->
  <amp-script layout="container" script="affilimate">
    <p><a href="https://amzn.to/12345">Go to Amazon</a></p>
  </amp-script>

</body>

Current AMP values

At time of writing, the current script version is: e893f3356 and Script Hash is sha384-dJzz2a9NrL9ejaoLdhgeoNe9l9J_sjgzy1TgDlM2u39UuneIqFa0DgrbaWdM9jRN. You can find your API token by taking it from the content parameter of the meta tag shown in your General Settings.

Affilimate's script will consume approximately 5,700 bytes of the maximum 150,000 bytes of scripts allowed on an AMP page.

Step 3. Set up Canonical URL tracking

Contact our Support team ( support@affilimate.com) and tell them you're using AMP, and want to have us enable Canonical URL tracking for you.

This will allow you to track analytics on URLs that look like:

https://www-yoursite-com.cdn.ampproject.org/v/s/www.yoursite.com/path-to-your-page/amp/?amp_js_v=0.1

But based on your canonical URL (meaning your main site URL) instead of the hosted AMP version.

So instead this URL would show up in your Content Analytics like:

https://www.yoursite.com/path-to-your-page/

And your commissions will all be attributed to the canonical version of the page on your website, regardless of whether they originated from AMP.

Step 4. Test your setup

To test your setup, load the AMP version of a page which contains tracked affiliate links.

Open the Chrome Developer Tools, and navigate to the Network tab. Do a test click on an affiliate link, and search for "tracklink" in the search bar:

If your AMP setup was successful, you'll see a link click event being send to the Affilimate tracking server.

Step 5. Apply your setup to the production server

After verifying that your AMP site is functioning as expected, you can apply these changes to your production server, and testing again.

Have questions? Contact us at support@affilimate.com anytime.

Last Updated 8/7/2022

Try the affiliate analytics platform for content websites

Affilimate aggregates all your affiliate commissions in one place, and then adds the missing attribution data you need to maximize your affiliate revenue from every post you publish.

Create your dashboard   Get a demo

 Free 15-day trial   No credit card required


Affilimate Analytics App
Affilimate
Newsletter
Monica

Hey, I'm Monica.

I'm the co-founder of Affilimate.

Once per month, I send insider tips and strategies for affiliates in this newsletter.

It's short, practical, and original. Try it out:

No spam, unsubscribe anytime.

AffilimateBy Adaero Software