GTM UnconditionalFiring

From Wiki

Jump to: navigation, search

Português

Contents

[-] Google Tag Manager - Template Integration

Google Tag Manager - Template Integration

Step 1 - Installing the Journey Tag

The Awin Journey Tag is a JavaScript library that contains all the necessary functions for the Awin tracking to work as expected.

The Journey Tag NEEDS to fire on all possible landing pages of your website! We ask this is done, because the Journey Tag is responsible for the creation of a first party cookie when the user reaches the website. As the user can enter the website through multiple possible landing pages apart from the website's home page, we need to cover all entrance possibilities, therefore, we need the Journey Tag to fire on all pages.


If the user enters through a page, that does not contain the Journey Tag, we won't measure anything.


1) Navigate to "Tags"


2) Click “New” and choose the ‘Awin Journey’ tag.

4) Enter your advertiser ID provided by your Integrator

5) Select "All Pages" as the trigger

6) Name and save this tag appropriately

Step 2 - Automatic de-duplication and the Channel Parameter

This allows Awin’s conversion tag to identify which was the last paid media to generate the last click in the user’s journey before the checkout, this way, Awin’s platform can determine which transactions came from Awin and which didn’t, thus having an automatic de-duplication performed.

1) Create a new variable and name it “Awin - ChannelCookie”, this should be a First Party cookie variable:

2) Name the cookie this way “AwinChannelCookie”:

3) Create a new trigger and name it “Awin – Source Trigger”, this should be a DOM Ready type trigger:

4) Change this to fire on “Some DOM Ready events” and change the firing rules to “PageURL”, “Matches RegEx”, “((.*)utm_source=(.*))|((.*)gclid=(.*))”. (Without quotes):

5) Create a new tag and name it “Awin - Create Cookie Channel”, this should be a Custom HTML type tag:

6) Add the following code to this tag:

<script>
    var Data = new Date();
    var latency;
    //cookiePeriod should reflect what is in the contract, default is 30 days.
    var cookiePeriod = 30;
    var source;
    var sourceParameter = "utm_source";
    var queryString = window.location.search;
    var urlParams = new URLSearchParams(queryString);
 
    Data.setTime(Data.getTime() + (cookiePeriod * 24 * 60 * 60 * 1000));
    latency = Data.toUTCString();
 
    //Check if last click was Awin, and if not other paid medias that use "utm_source" or other parameters such as google ads
    if (urlParams.get(sourceParameter) != "awin" && urlParams.get(sourceParameter) != null || window.location.href.indexOf("gclid") > -1) {
        source = "other";
    } else {
        source = "aw";
    }
 
    document.cookie = "AwinChannelCookie=" + source + "; expires=" + latency + ";path=/; Domain=.INSERT_YOUR_DOMAIN.COM";      
</script>

7) Edit the code above where it says “INSERT_YOUR_DOMAIN_HERE.COM”, to reflect your website’s domain, please keep the "." before your domain as it will take into consideration any subdomain from your website.

Step 3: Define the Awin sale tracking

1) Create a new Awin Tag and select the ‘Awin Conversion’ Tag.

2) Defining you DataLayer values, in case you don't know how to map DataLayer variables, here is a guide you can follow on How to map DataLayer variables in GTM

3) Select the trigger that fires once a conversion or the desired event occurs. (The "success" page for conversions, or an confirmation event for leads).

4) Click ‘Save’ and you will then be asked to rename the Tag but you can leave it as it is.

5) Click ‘save’ and you should now have two Tags listed in the Tags table.

Step 4 - Product Level Tracking (PLT)


This step should only be followed by e-commerces, if you do not have an e-commerce, please ignore this step.

Product Level Tracking allows the advertiser to generate much detailed deports, it shows the performance for each product in the shoppinf cart individually, this is specially relevant for e-commerces.

1) Create a new tag of type "Custom HTML" and paste the following Code:

<script type="text/javascript">
var transactionProducts = {{transactionProducts}};
AWIN.Tracking.Sale.plt = '';
for (i = 0; i < transactionProducts.length; i++) {
AWIN.Tracking.Sale.plt += "AW:P|XXXXX|{{Awin - Transaction ID}}|" +
transactionProducts[i]['id'] + "|" +
transactionProducts[i]['name'] + "|" +
transactionProducts[i]['price'] + "|" +
transactionProducts[i]['quantity'] + "|" +
transactionProducts[i]['sku'] + "|" +
"DEFAULT" + "|" +
transactionProducts[i]['category'] + "\n";
}
var basketForm = document.createElement('form');
basketForm.setAttribute('style', 'display:none;');
basketForm.setAttribute('name', 'basket_form');
var basketTextArea = document.createElement('textarea');
basketTextArea.setAttribute('wrap', 'physical');
basketTextArea.setAttribute('id', 'aw_basket');
basketTextArea.value = AWIN.Tracking.Sale.plt;
basketForm.appendChild(basketTextArea);
document.getElementsByTagName('body')[0].appendChild(basketForm);
<!----End Product Level Tracking--->
</script> 
 
<script defer="defer" src="https://www.dwin1.com/XXXXX.js" type="text/javascript"></script>

2) Adjust the variables so that they reflect the variables in your GTM container. Here is a description of the necessary variables:

* {{transactionProducts}} - Needs to reflect the array of products inside of the shopping cart..
* {{Awin - Transaction ID}} - Needs to receive the order ID.
* XXXXX - Should be changed to your MID (Merchant ID), There are two instances of this in the previous code, please update both!

Step 6 - Tests

1) All done! Now just publish the changes!

2) You can follow this guide on How to Test the Awin Tags or contact your Integrator for further assistance!

Privacy

Due to new European legislation regarding how websites store information about you, AWIN is updating its privacy policy. You can see the new version of our policy here. If you would like to see the information we capture on this website, please click here for further details. In order to accept cookies on this site please click the 'I ACCEPT' button