The Complete Guide to AWIN Journey Tag Setup and Conversion Tracking with Google Tag Manager

Awin is one of the largest affiliate networks in the world. It brings together thousands of advertisers and publishers around the world to deliver conversions to clients. With affiliate marketing, advertisers can reach new users by working with publishers who, through their own user base, are able to promote products and services of the potential advertisers. Publishers earn money by promoting advertisers’ products and services from a commission on each sale. 

The main issue with affiliate marketing is the ability to recognize which transactions were made by users who came from publishers’ websites and which came from other channels. This issue is known as conversion duplication. To help resolve this issue Awin has developed a proprietary system and tools so that both advertisers and publishers know which transactions came from publisher’s website.

This article is primarily directed at advertisers who, after signing the contract with Awin, are required to implement appropriate tracking codes on their website that allow transaction tracking. Awin, of course, provides all the necessary information regarding implementation, but because we, as an agency, have undergone the whole process of integration of the Awin system for our clients, we will share the inside and outs of the whole implementation process via Google Tag Manager.

Table Of Contents

  1. Planning AWIN implementation
  2. AWIN Implementation Process Overview
  3. AWIN Journey Tag Implementation with Google Tag Manager
  4. AWIN Conversion Tag Setup
  5. What is transaction de-duplication in affiliate programs?
  6. Defining commission groups
  7. Fall-back Conversion Pixel
  8. Product Level Tracking
  9. Putting it all together
  10. How To Implement Conversion Tracking Code Using Google Tag Manager
  11. What is Server To Server Tracking and how to implement it?
  12. FAQ
  13. Summary

How to Plan AWIN Implementation

After signing the contract with Awin, you will receive integration support in the form of a technical consultant. The consultant will provide you with all the necessary information regarding the implementation of Awin tracking codes, and will also answer all your questions related to the QA process.

First, you will receive a technical questionnaire to complete from the consultant. The questionnaire will help the consultant determine what you need when it comes to implementing the Awin’s system and what implementation steps should be taken. The questionnaire includes, among others, the following questions:

  • Do you use any systems to implement website tracking? In our case it was Google Tag Manager.
  • Do you have a single thank-you page for purchases in multiple languages?
  • Do you intend to deduplicate transactions to other marketing channels and how do you want to do it? I will write more about deduplication later in the article. In our case, we chose deduplication using the Awin channel parameter.
  • Will you use additional parameters in the url to track traffic in e.g. Google Analytics?
  • What payment gateways do you use?
  • Do you have the option of placing orders on the website, e.g. by phone? It is about whether the user has the option of placing an order in a different way than via a website, e.g. by telephone. In such cases, you must specify how you want to handle such transactions, e.g. by hiding the phone number for users who came from the affiliate link.
  • How will you transfer the order value? Including tax and delivery cost, or net value only?
  • How do you want to specify sales commissions? Do you want to set a fixed commission, or depending on the products’ users buy?
  • Can you provide a dummy credit card for testing?
  • Will you provide a product feed for publishers and in what format do you want to provide this feed?
  • How will you deliver the feed?

AWIN Implementation Process Overview

The implementation of Awin tracking is based on two levels, client-side (browser) and server-side tracking.

First, we’ll introduce client-side tracking. The client-side tracking code actually consists of several minor scripts:

  • Master Tag
  • Conversion Tag
  • Fall-back Conversion Pixel
  • Product Level Tracking
  • Master Tag

The Master Tag code, also known as Journey Tag, is a JavaScript library that contains all the necessary functions needed for Awin tracking. This code should be implemented on every page of the website, including the thank-you page after purchase. It’s recommended to trigger it as late as possible, so it should be implemented immediately before the closing </body> tag. Below is an example of the script to be implemented on the site:

<script defer = "defer" src = "https://www.dwin1.com/{{$ADVERTISER_ID}}.js" type = "text / javascript"> </script>

Pay attention to the {{$ ADVERTISER_ID}} parameter. You should provide your ID here, which you will get from your consultant.

AWIN Journey Tag Implementation with Google Tag Manager

Implementing the Master Tag code using GTM is very simple. Just go to the tags section and then add a new tag.

You must select the AWIN Journey tag from the list of available tag types.

Then you need to provide your Advertiser ID and add an All Pages trigger as well as an exception that will block the tag from being called on the thank you page for your purchase. This is due to the fact that the conversion code, which will be presented later in the article, must be configured before the Master Tag code. In order to add an exception, create a trigger that would normally be responsible for calling the tag on the thank you page for purchase, but in our case, we will use it as an exception for the Master Tag.

We have just implemented the first Awin tracking element on the client’s side.

AWIN Conversion Tag Setup

The next step is to implement the conversion tracking code or Conversion Tag. It is responsible for transferring the purchase information to the Master Tag code, which then sends the information to the Awin servers. 

Below you will find an example of how the Conversion Tag looks and what parameters it contains.

<script type = "text / javascript">
/ *** Do not change *** /
var AWIN = {};
AWIN.Tracking = {};
AWIN.Tracking.Sale = {};
/ *** Set your transaction parameters *** /
AWIN.Tracking.Sale.amount = {{totalAmount}};
AWIN.Tracking.Sale.channel = {{channel}};
AWIN.Tracking.Sale.orderRef = {{orderReference}};
AWIN.Tracking.Sale.parts = {{commissionGroupCode}};
AWIN.Tracking.Sale.currency = {{currencyCode}};
AWIN.Tracking.Sale.voucher = {{voucherCode}};
AWIN.Tracking.Sale.test = {{isTest}};
</ Script>
  • {{totalAmount}} – the total value of the transaction minus the value of the discount coupon code that was used. Depending on how you determined the value of the transaction in the questionnaire, this value could include tax value and delivery costs.
  • {{channel}} – this parameter determines which channel the user came from. For users who came from the Awin affiliate link, the value of this parameter should be “aw”. If you have indicated in the questionnaire that you want to deduplicate transactions with other channels, then the value of this parameter should specify the channel from which the user came. More about channel deduplication is outlined later
  • {{orderReference}} – Using this parameter, we pass the transaction identification number
  • {{commissionGroupCode}} – this parameter defines commission groups and values ​​assigned to particular commission groups. More on this later in the article.
  • {{currencyCode}} – this parameter is responsible for the transaction currency
  • {{voucherCode}} – with this parameter we pass the coupon code that was used during the transaction
  • {{isTest}} – the value of this parameter can be set to 0 or 1. A value of 1 means that the request will not be sent and processed by Awin’s servers. This parameter is used when testing the implementation and we do not want our test transactions to be registered. Ultimately, the value of this parameter should be 0 when we finish the implementation and we are sure that everything is correct.

Before we proceed to implement the Conversion Tag with GTM we must consider two issues. Firstly, how we specify the value of the channel parameter. If you had stated in the technical questionnaire that you do not want to deduplicate transactions against other paid channels, then the value of this parameter should always be specified as ‘aw’. However, if in the question you marked that you want to deduplicate transactions then the value of this parameter should specify the traffic channel from which the user came.

What is conversion de-duplication in affiliate programs?

Imagine a situation in which the publisher runs their campaigns on Awin’s platform and Google Ads. 

Scenario A: A user visits the publisher’s website clicks on an affiliate link, which takes him to your website. Then selects a product and adds it to the basket, but abandons the purchase. He then sees the Google Ads ad and clicks on it, which takes him back to your website, and consequently, he completes the transaction. 

In this situation, in order not to pay the publisher’s commission twice for the same transaction, transaction deduplication is applied to the Google Ads channel. In effect, the conversion is assigned to the last channel with which the user was interacting, in this case, Google Ads.

In order to deduplicate transactions, we must first identify which channel the user came from. We can use UTM parameters for this, which are added to paid links. In our case, we used the utm_medium parameter to determine the channel from which the user came. If the user clicks on the Awin affiliate link, the utm_medium = aw parameter is also added to it. On this basis, we are then able to determine from which channel the user came and pass this value later using the channel parameter in the Awin conversion code. On the other hand, if the user comes from a Google Ads link the utm_medium = paid_search parameter is assigned.

In order to pass the value of the utm_medium parameter in the Awin conversion code, we must recognize that such a parameter appeared on the landing page’s URL and then save its value in a cookie. For this purpose, we can use a special script called Source Handler, which checks whether the URL contains utm_medium parameter and then saves its value in a cookie.

In order to add a Source Handler script using GTM, we must first add a new Custom HTML tag. So we go to the Tags section and then click the New button. Next, from the list of available tags, we choose the Custom HTML type.

<script type="text/javascript">
var iCookieLength = 30; // Cookie length in days
var sCookieName = "source"; // Name of the first party cookie to utilise for last click referrer de-duplication
var sSourceParameterName = 'utm_medium'; // The parameter used by networks and other marketing channels to tell you who drove the traffic

var _getQueryStringValue = function (sParameterName) {
    var aQueryStringPairs = document.location.search.substring(1).split("&");
    for (var i = 0; i < aQueryStringPairs.length; i++) {
        var aQueryStringParts = aQueryStringPairs[i].split("=");
        if (sParameterName.toLowerCase() == aQueryStringParts[0].toLowerCase()) {
            return aQueryStringParts[1];
        }
    }
};

var _setCookie = function (sCookieName, sCookieContents, iCookieLength) {
    var dCookieExpires = new Date();
    dCookieExpires.setTime(dCookieExpires.getTime() + (iCookieLength * 24 * 60 * 60 * 1000));
    document.cookie = sCookieName + "=" + sCookieContents + "; expires=" + dCookieExpires.toGMTString() + "; path=/;";
};
 
 
if (_getQueryStringValue(sSourceParameterName)) {
    _setCookie(sCookieName, _getQueryStringValue(sSourceParameterName), iCookieLength);
}
</script>

This part is very tricky and we highly recommend doing this with experienced Web Analysts to avoid any problems and double paying for conversions. If you need help with this implementation please contact us using the contact form.

After we add and configure the script code to capture the utm_medium parameter value, we need to add the appropriate trigger to the tag. In our case, we need to add the All Pages trigger, because the script for capturing the utm_medium parameter value must run on each page of the website.

After we configure our tag with the script to capture the utm_medium parameter, we need to create in GTM a variable that will read the value of the cookie that will be set by the script. We’ll use this variable later in the actual Conversion Tag script.

In order to create a variable, we first need to go to the Variables section in GTM and then add a new 1st party cookie variable. As the variable’s value, we give the name of the cookie that will store information about the source of the user’s visit. In our case, it is the name “source”.

Defining commission groups

The second key element after setting up the conversion tag code is defining the {{commissionGroupCode}} parameter. The general scheme for determining the value of this parameter is as follows: {{commission_group_code}}: {{value_assigned_to_project_group}}

For Example:

If the value of your transaction was 100 € and you have only one commission group specified in your system for which the commission will be calculated, then the value of the parts parameter will be:

AWIN.Tracking.Sale.parts = DEFAULT: 100;

You decide what committee groups you want. The consultant should help you define the appropriate commission groups. For example, if you want to charge commissions depending on the brand of purchased products, then you may want to specify two groups of commissions, one for each brand. Then, if the user as part of the transaction would buy an A brand product for 50 € and a B brand product for 50 €, then the AWIN.Tracking.Sale.parts parameter would be as follows:

AWIN.Tracking.Sale.parts = BRANDA: 50 | BRANDB: 50;

Commission groups together with their values ​​can be separated by a vertical dash “|”.

A sample conversion code with sample values ​​can be found below:

<script type = "text / javascript">
/ *** Do not change *** /
var AWIN = {};
AWIN.Tracking = {};
AWIN.Tracking.Sale = {};
/ *** Set your transaction parameters *** /
AWIN.Tracking.Sale.amount = 100;
AWIN.Tracking.Sale.channel = "aw";
AWIN.Tracking.Sale.orderRef = "ABC123456";
AWIN.Tracking.Sale.parts = BRANDA: 50 | BRANDB: 50;
AWIN.Tracking.Sale.currency = "EUR";
AWIN.Tracking.Sale.voucher = "SUMMERSALES";
AWIN.Tracking.Sale.test = 0;
</ Script>

Fall-back Conversion Pixel

One of the required elements of Awin tracking is also implementing the so-called Fall-back Conversion Pixel. This is a short tag added using the img element to the page code. The parameters used in this tag are analogous to the parameters we use in the Conversion Tag script.

<img border = "0" height = "0" src = "https://www.awin1.com/sread.img?tt=ns&tv=2&merchant=1001&amount={{totalAmount}}&ch={{channel}}&parts = {{commissionGroupCode}} & ref = {{orderReference}} & cr = {{currencyCode}} & vc = {{voucherCode}} & testmode = {{isTest}} "style =" display: none; " width = "0">

Product Level Tracking

Another important element of the conversion code, though optional, is the so-called Product Level Tracking, which allows you to track the details of purchased products during the transaction. As a result, more detailed and extensive reporting of purchased goods will be available in the Awin system. To do this, you must implement a code that will deliver relevant information to Awin. The code should be added to the page using a hidden form element containing a row with product information in the below format.

AW: P | {{advertiserId}} | {{orderReference}} | {{productId}} | {{productName}} | {{productItemPrice}} | {{productQuantity}} | {{productSku}} | {{commissionGroupCode} } | {} {} ProductCategory

Below you will find an example of JavaScript code that prepares the next row in the above format and then adds it to the hidden HTML form containing subsequent lines with products.

<Script>
var transactionProducts = {{DL - purchaseProducts}};
AWIN.Tracking.Sale.plt = '';

for (i = 0; i <transactionProducts.length; i ++) {
AWIN.Tracking.Sale.plt + = "AW: P | {{CS - awinID}} | {{DL - transactionId}} |" +
transactionProducts [i] ['id'] + "|" +
transactionProducts [i] ['name'] + "|" +
transactionProducts [i] ['price'] + "|" +
transactionProducts [i] ['quantity'] + "|" +
transactionProducts [i] ['id'] + "|" +
transactionProducts [i] ['brand'] + "|" +
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);
</ Script>

Putting it all together

Let’s put all the elements we discussed together before we add the codes using GTM.

Firstly, we add the Fall-back Conversion Pixel code. Then the Conversion Tag together with Product Level Tracking. Finally, we add the Master Tag code. In this configuration, we can be sure that the conversion code will be set up and called before the Master Tag. For this purpose, during the configuration of the Master Tag code, we added an exception to this tag so that it does not run on the thank you page for the purchase, because it will be called along with the conversion code.

// Fall-back Conversion Pixel
<Script>

  var AWINReferrer = {{CK - source}} || 'aw';
   
  var sProtocol = (location.protocol == "http:")? "http": "https";
  var awPixel = new Image (0, 0);
  awPixel.src = sProtocol + ": //www.awin1.com/sread.img? tt = ns & tv = 2 & merchant = {{CS - awinID}} & amount =" + '{{CJS - awinRevenue}}' +
    "& ch =" + AWINReferrer +
    "& parts =" + {{CJS - awinParts}} +
    "& ref =" + '{{DL - transactionId}}' + "& vc =" + '{{DL - transactionCoupon}}' + "& cr =" + '{{DL - currencyCode}}' +
    "& TESTMODE = 0";
 
</ Script>

// Conversion Tag and Product Level Tracking
<script type = "text / javascript">
// <! [CDATA [
    / *** Do not change *** /
    var AWIN = {};
    AWIN.Tracking = {};
    AWIN.Tracking.Sale = {};
 
    / *** Set your transaction parameters *** /

    AWIN.Tracking.Sale.amount = '{{CJS - awinRevenue}}';
    AWIN.Tracking.Sale.currency = '{{DL - currencyCode}}';
    AWIN.Tracking.Sale.orderRef = '{{DL - transactionId}}';
    AWIN.Tracking.Sale.parts = '{{CJS - awinParts}}';
    AWIN.Tracking.Sale.voucher = '{{DL - transactionCoupon}}';
    AWIN.Tracking.Sale.test = '0';
    AWIN.Tracking.Sale.channel = AWINReferrer;

  var transactionProducts = {{DL - purchaseProducts}};
    AWIN.Tracking.Sale.plt = '';

    for (var i = 0; i <transactionProducts.length; i ++) {
         
      AWIN.Tracking.Sale.plt + = "AW: P | {{CS - awinID}} | {{DL - transactionId}} |" +
                        transactionProducts [i] ['id'] + "|" +
                        transactionProducts [i] ['name'] + "|" +
                        transactionProducts [i] ['price'] + "|" +
                        transactionProducts [i] ['quantity'] + "|" +
                        transactionProducts [i] ['sku'] + "|" + transactionProducts [i] ['brand'] + "|" + 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);
   
//]]>
</ Script>

// Master Tag
<script src = "https://www.dwin1.com/{{CS - awinID}}. js" type = "text / javascript" defer = "defer"> </script>

How To Implement Conversion Tracking Code Using Google Tag Manager

After we have prepared the conversion code, which should be triggered on the thank you page after purchase, we can add it using a Custom HTML tag in GTM. To do this, go to the Tags section, and then add a new tag, copy the code above. Remember to configure GTM variables and replace them with the appropriate parameters in the code. As a trigger in our case, we used a custom event that is called on the thank you page for the purchase using dataLayer. Thanks to this, we are sure that when the tag is launched, all variables from dataLayer are available.

What is Server To Server Tracking and how to implement it?

The last element we have to implement is Server to Server tracking. Unfortunately, we cannot configure this kind of tracking using GTM, so you must ask developers for help.

The code to be implemented on the server’s side consists of two elements.

The first is to capture the awc parameter from the landing page URL where the user was after clicking on the affiliate link. Each time a user clicks on the Awin affiliate link and is taken to the landing page, the URL will have the awc parameter attached and the string assigned to it. The value of this parameter should be captured and stored in a cookie. Sample code in PHP that can be used for this can be found below:

<? Php
function setAwc () {
    if ($ _GET ['awc']) {
        setcookie ("awc", $ _ GET ['awc'], time () + 60 * 60 * 24 * 365, "/", "example.com", true, true);
    }
}
?>

The second element to implement is the correct conversion code. This code resembles the code used for Fall-back Conversion Pixel. The parameters to be sent are the same as for the conversion code with two small differences.

The first is the additional parameter cks, in the URL using it we need to send the value of the captured awc parameter.

The second change is the tt parameter, which should be changed from tt = ns to tt = ss.

Also pay attention to the destination address to which we send the request. In the case of the Fall-back Conversion Pixel code, it was https://www.awin1.com/sread.img, while in the case of the S2S code it was https://www.awin1.com/sread.php.

https://www.awin1.com/sread.php?tt=ss&tv=2&merchant={{advertiserId}}&amount={{totalAmount}}&ch={{channel}}&parts={{commissionGroup}}:{{totalAmount }} & vc = {{}} & voucher_code cr = {{}} & currencyCode ref = {{}} & orderReference TESTMODE isTest = {{}} & cks = {{}} awc

An example PHP code that should be implemented on the server-side can be found below:

<? Php

$ url = "https://www.awin1.com/sread.php?tt=ss&tv=2&merchant={{advertiserId}}";
$ url. "& amount =". TotalAmount {{}};
$ url. = "& ch =" {{channel}};
$ url. = "& cr =". CurrencyCode {{}};
$ url. = "& ref =". OrderReference {{}};
$ url. = "& parts =". CommissionGroup {{}} {{}} totalAmount;
$ url. = "& testmode = 0 & vc =". Voucher_code {{}};
if (isset ($ awc)) {
    $ url. = "& cks =". $ Awc; // Populate the Awin click checksum if one is associated with the conversion
}

$ c = curl_init ();
curl_setopt ($ c, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt ($ c, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ c, CURLOPT_URL, $ url);
curl_exec ($ c);
curl_close ($ c);

?>

FAQ

What is AWIN conversion pixel?

The Conversion Pixel is a way for AWIN to track conversions. It is usually a javascript code that needs to be implemented on the “thank-you” page after purchase.

What is AWIN conversion de-duplication?

Conversion de-duplication is a way to attribute conversions to the appropriate channel. If we have two channels, for example, Google Ads and AWIN and each channel have one conversion counted but in reality, our system has one sale. With de-duplication we can help AWIN determine if the conversion came from their platform or from Google Ads. In the end, the client does not pay double for the same sale.

What is AWIN server-to-server tracking?

Sometimes problems arise that can hinder client-side tracking like for example javascript errors, adblocks, etc. Server-side tracking is a fall-back system to ensure the conversion data flows to AWIN and is important when we want to have accurate data.

Summary

In order to implement Awin tracking in GTM, we need to combine three new tags. The first is the tag to capture the value of the utm_medium parameter, which in our case determines the channel from which the user came. The second tag is Master Tag, i.e. the main Awin tracking code, which must be called on every page of the website except the thank-you page after purchase. The third tag we need to implement is the conversion code called Conversion Tag. This tag also includes the Fall-back Conversion Pixel script and the Product Level Tracking script, as well as Master Tag. All these scripts are so-called client-side tracking or browser tracking and can be implemented and managed using GTM. However, Awin also requires the implementation of conversion tracking using the Server To Server script, which sends conversion information from your servers straight to Awin servers

If you are tracking, all of your tracking questions should be answered by your consultant assigned to you at the contract signing stage. However, remember that the implementation of the tracking itself is on your side.

If you have any questions or need help coordinating the implementation of Awin tracking for your website, you can always contact us, we’ll be happy to help.

Share on facebook
Share on twitter
Share on linkedin