Skip to main content
Skip table of contents

Alli Audience Gateway Placement Instructions

The following documentation will walk through the placement instructions for the Alli Audience Gateway. The Alli Audience Gateway powers server-to-server enablement for the future of cookieless tracking to media platforms such as Facebook, Snapchat, and Pinterest.

If you have any questions following this set up, reach out to technicalsolutions@pmg.com.

The setup follows 3 steps:

  • Setting up the EventID

  • Setting up the Alli Audience Gateway Events

  • Adding the event_id to traditional cookie tags

Step 1: Setting up the Event ID

One variable referenced throughout the documentation is event_id. This event_id is used for deduplication in platforms. Meta provides an explanation of deduplication here but in summary, because media platforms, such as Meta, are now receiving two signals - from the browser with the cookie and from the server, the event_id is used to deduplicate those events on the platform.

This event_id is flexible in set up but has the following requirements: 

  1. The event_id needs to be distinct for each page load.

  2. The same event_id needs to be sent for each platform event and corresponding Alli Audience Gateway. For example, the event_id value needs to be the same for the Facebook Pixel Page View and the Alli Audience Gateway Page View. 

  3. event_id must be unique for every distinct event type. It can be different for two different events so as long the events are different. 

    1. Good Example: 

      1. Event Page View on Page A: 1678375710236.233028.13

      2. Event Add to Cart on Page A: 1678375710236.233028.13

      3. Explanation - Although the event_id’s are the same, it's for two different events that may happen on the same page load therefore the platform will deduplicate accordingly. 

    2. Bad Example: 

      1. Event Page View on Page A: 1678375710236.233028.13

      2. Event Page View on Page B: 1678375710236.233028.13

      3. Explanation - Both the event_id and event are the same, so although this may be two different PageViews, it will be deduplicated in platform as a single page view.

GTM Instructions

There are two ways to set up the EventID in Google Tag Manager (GTM):

Option 1: Using a Container Template

Download the container template from the provided link.

Import the template into GTM. If you're unfamiliar with importing GTM files, follow the provided instructions.

The template includes the necessary EventID code and variables for Alli Audience Gateway events.

Option 2: Manual Setup

  1. Create a Variable Template:

    Navigate to GTM and select "Template" from the left sidebar.

    Click "New Variable Template".

    Name the template eventID.

  2. Configure the Template:

    Fields Tab: No changes needed.

    Code Tab: Insert the code snippet below.

    Permissions Tab: Create a new key called _randomPageId and set permissions to Read and Write.

  3. Create a Variable:

    Navigate to "Variables" on the left sidebar.

    Click "New Variable" and name it eventID.

    In the Variable Configuration, select the eventID template you just created.

    Now, the eventID variable is ready to be referenced in the Alli Audience Gateway code.

Code Snippet

JS
const copyFromDataLayer = require('copyFromDataLayer'); 
const setInWindow = require('setInWindow'); 
const copyFromWindow = require('copyFromWindow'); 
const getTimestampMillis = require('getTimestampMillis'); 
const generateRandom = require('generateRandom'); 
var eventId = copyFromWindow('_randomPageId'); 
if (!eventId) { 
  eventId = getTimestampMillis() + '.' + generateRandom(100000, 999999); 
  setInWindow('_randomPageId', eventId, false); 
} 
 
return eventId + "." + copyFromDataLayer('gtm.uniqueEventId') || '0';

Step 2: Setting up the Alli Audience Gateway Events

The following are the code snippets for the Alli Audience Gateway. When you are assigning trigger events, the trigger events should be the same as your media pixels.

Base Pixel

JS
<script> 
    (function() { 
        if (!('alli' in window)) { 
            window.alli = function () { 
                window.alli.q.push(arguments); 
            }; 
            window.alli.q = []; 
        } 
        var script = document.createElement('script'); 
        script.src = 'https://cdn.allitrk.com/v1/allitrk.js'; 
        script.async = true; 
        var firstScript = document.getElementsByTagName('script')[0]; 
        firstScript.parentNode.insertBefore(script, firstScript); 
    })(); 
    alli('init', {key: '400cdb64-036c-44a7-aab2-6fc9dacbfabb', collector: 
'https://collector.allitrk.com/v1/collect'}); 
</script> 

PageView

JS
<script> 
    alli('pageView', {event_id: {{eventID}}}); 
</script>

ViewContent

JS
<script> 
         alli('viewContent',  {  
            content_ids: {{content_id}}, 
            content_type: '{{content_type}}', 
            value: Number('{{value}}'),    
            currency: {{currency}}, 
            email:{{email}},                                                                
            eventID: {{eventID}}} 
          ); 
</script>

AddToCart

JS
<script> 
        alli('addToCart', {  
            content_ids: {{content_id}}, 
            content_type: '{{content_type}}', 
            value: Number('{{value}}'),    
            currency: {{currency}}, 
            email:{{email}},                                                                
            eventID: {{eventID}}} 
          }; 
</script>

Purchase

JS
<script> 
    alli('purchase', {  
        value: 1234,  
        event_id: '12345',  
        transaction_id: '1234',  
        first_name: 'John',  
        dob: '01/01/01',  
        content_ids: ['123', '234', '345'],  
        content_name: 'product',  
        content_type: 'product',  
        num_items: 3,  
        city: 'example_city',  
        state: 'example_state',  
        zip: '11111',  
        country: 'USA',  
        last_name: 'Smith',  
        quantity: 3,  
        currency: 'USD',  
        delivery_category: 'In-Store',  
        email: 'randomemail@email.com',  
        phone: '1234567890',  
        contents: [{ 
            id: 'some-item-id', 
            price: 123.45, 
            quantity: 4, 
            category: 'item-category' 
        }, { 
            id: 'some-other-item-id', 
            price: 3.63, 
            quantity: 1, 
            category: 'item-category' 
        }] 
    }); 
</script>

Step 3: Adding the Event ID to traditional cookie tags 

The last and final step is to add the eventID to existing Platform tags. As explained in the "Setting up EventID" tab, the event ID is used to deduplicate the Server connection from the Browser connection to ensure no event is counted twice. In order to do that, you need to update the PageView, ViewContent, AddToCart, and Purchase Tags for Meta, TikTok, Pinterest and Snapchat.

Meta
For Meta, you need to update each event code to have one more object parameter to pass eventID through. Example: fbq('track', 'PageView', {}, {eventID: {eventID} });

TikTok
If you are using the TikTok GTM template, under "Parameter Override", you will see a field that you will pass the eventID variable through. Example: ttq.track('PageView', {event_id:{eventID})

Pintrest
For Pinterest, you will pass through a new parameter in each of your events called event_id. Documentation here.

Snapchat
For Snapchat, you need to pass through a new parameter in each of your events called client_dedup_id.


Amazon

For Amazon, you need to pass through a new parameter in each of your events called clientDedupeId. Example Below:

amzn("trackEvent", "purchase", {

custom: {

clientDedupeId: "YOUR_DEDUPE_ID_HERE" // e.g., "order123456" or any

unique identifier

},

// You can include other standard purchase parameters as needed

value: 100.00,

currency: "USD",

orderID: "123456"

});

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.