We do not recommend to use a Google Tag Manager (GTM) container as a place to install the tracking code, as it can be blocked by third-party extensions. If it is possible, we advise to use the standard integration method via tracking code.
Admitad Partner Network does not provide technical support for the platform and is not responsible for programs that are affected by the use of GTM.
Purpose of the tracking code
The tracking code is a JavaScript code that you should place on your website.
Tracking code tracks users' actions on your website and sends the data to the Admitad Partner Network statistics. When the tracking code is triggered, Admitad Partner Network's server receives a request with information about this action (order ID, order amount, etc.).
Besides, the tracking code is used for order deduplication and crossdevice tracking.
Note:
- When the site is updated, it is necessary to check out that the code has not been deleted and continues working.
- If there is a mobile version of the website or a mobile app, quick order forms, or 1-click order forms, make sure that they are also integrated.
Admitad transition link
To get started with Admitad Partner Network, provide a link* to your website with all GET parameters and UTM parameters you need.
Link example
https://site.ru/?utm_source=admitad&utm_medium=cpa
This link will be used for generating affiliate links for our publishers. In the future, they will place affiliate links on their ad spaces and drive traffic to your website.
*You can provide several links, but only one of them will be set as a default link of your program.
Installation of the tracking code in Google Tag Manager
Hereinafter we will use the abbreviation GTM for Google Tag Manager.
This guide contains a detailed description of the steps you need to make in order to install the tracking code in a GTM container. However, it only serves as a demonstration. All variables, macros, rules, and tags are just an example and must be replaced with your own.
If you need more help, visit the Google Tag Manager Forum.
To place the Admitad Partner Network tracking code in GTM, do the following:
- register and install the GTM;
- initialize the data layer and set up the variables;
- set up the triggers;
- set up the tags;
- set up the transfer of the unique promo codes.
Registration and installation of the GTM container on your website
To access GTM you need to have a Google account. If not, create an account at https://accounts.google.com and sign in at https://tagmanager.google.com/.
Click "Add a New Account". Enter account name and click "Continue".
Create a GTM container for your website. Name it as you want.
After you accept the Terms of Service Agreement, you will see the GTM code to install on your website.
Paste the code in tags<head> and <body> onto every page of your website.
Now we can move on to the setup of tags, variables and triggers.
Initialization of the data layer and setup of the variables
To pass information about an order from your website to your Tag Manager container, use a special object called dataLayer. Read more about dataLayer here.
Initialize dataLayer on a thank you page above the GTM code. In the example below an enhanced Google Analytics ecommerce method is used.
<script> window.dataLayer = window.dataLayer || []; dataLayer.push({ "transactionId": "sk1006", // internal order ID (not more than 100 characters) "transactionChannel": "adm", // deduplication parameter (for Admitad by default) "transactionAction": "1", // action code (defined during integration) "transactionProducts": [{ "sku": "1354471145550", // internal product ID (not more than 100 characters) "tariff": "2", // tariff code (defined during integration) "price": "300.00", // product price "priceCurrency": "RUB", // currency code ISO-4217 alfa-3 "quantity": "2" // product quantity }, { "sku": "1354471047246", "tariff": "2", "price": "500.00", "priceCurrency": "RUB", "quantity": "1" }] }); </script>
To set up GTM variables go to the “Variables” tab at the workspace and click “New”.
Select the variable type "Data Layer Variable".
Enter the name of the variable, data layer version, and default value. Save the variable.
When creating variables, use the values from the table below:
Data Layer Variable Name | Variable name | dataLayer Version | Default Value |
transactionId | orderNumber | Version 2 | |
transactionChannel | broker | Version 2 | adm |
transactionAction | category | Version 2 | |
transactionProducts | transactionProducts | Version 2 |
You should get the following list of variables.
Triggers setup
To set up triggers, go to the "Triggers" tab at the workspace and click "New".
Create a trigger of "Window Loaded" type.
Select an option "Some Window Loaded Events". In the example below the page will be defined as a thank you page, if its URL contains the "thank_you" substring. Add a similar rule for your website.
Name the trigger "TagTag conversion" and save it.
Add one more "Page View - Window Loaded" trigger. Select an option "All Pages Views". Name the trigger "TagTag common" and save it.
You should get the following list of triggers.
Tags setup
To set up tags, go to the "Tags" tab at the workspace and click "New".
Create a tag of "Custom HTML" type.
Paste the code below into the textbox. The code in theonerror attribute prevents erroneous blocking of the script loading by ad blockers and antivirus software.
-
<script src="https://www.artfut.com/static/tagtag.min.js?campaign_code={your_campaign_code}" async onerror='var self = this;window.ADMITAD=window.ADMITAD||{},ADMITAD.Helpers=ADMITAD.Helpers||{},ADMITAD.Helpers.generateDomains=function(){for(var e=new Date,n=Math.floor(new Date(2020,e.getMonth(),e.getDate()).setUTCHours(0,0,0,0)/1e3),t=parseInt(1e12*(Math.sin(n)+1)).toString(30),i=["de"],o=[],a=0;a<i.length;++a)o.push({domain:t+"."+i[a],name:t});return o},ADMITAD.Helpers.findTodaysDomain=function(e){function n(){var o=new XMLHttpRequest,a=i[t].domain,D="https://"+a+"/";o.open("HEAD",D,!0),o.onload=function(){setTimeout(e,0,i[t])},o.onerror=function(){++t<i.length?setTimeout(n,0):setTimeout(e,0,void 0)},o.send()}var t=0,i=ADMITAD.Helpers.generateDomains();n()},window.ADMITAD=window.ADMITAD||{},ADMITAD.Helpers.findTodaysDomain(function(e){if(window.ADMITAD.dynamic=e,window.ADMITAD.dynamic){var n=function(){return function(){return self.src?self:""}}(),t=n(),i=(/campaign_code=([^&]+)/.exec(t.src)||[])[1]||"";t.parentNode.removeChild(t);var o=document.getElementsByTagName("head")[0],a=document.createElement("script");a.src="https://www."+window.ADMITAD.dynamic.domain+"/static/"+window.ADMITAD.dynamic.name.slice(1)+window.ADMITAD.dynamic.name.slice(0,1)+".min.js?campaign_code="+i,o.appendChild(a)}});'></script>
Do not forget to change the value of {your_campaign_code} to the one you received at the beginning of the integration.
Now move on to the "Triggering" section below.
Set "TagTag Common" as a firing trigger and "TagTag conversion" as an exception.
Name the tag "TagTag common" and save it.
Add one more "Custom HTML" tag. Paste the code below into the textbox.
-
<script src="https://www.artfut.com/static/tagtag.min.js?campaign_code={your_campaign_code}" onerror='var self = this;window.ADMITAD=window.ADMITAD||{},ADMITAD.Helpers=ADMITAD.Helpers||{},ADMITAD.Helpers.generateDomains=function(){for(var e=new Date,n=Math.floor(new Date(2020,e.getMonth(),e.getDate()).setUTCHours(0,0,0,0)/1e3),t=parseInt(1e12*(Math.sin(n)+1)).toString(30),i=["de"],o=[],a=0;a<i.length;++a)o.push({domain:t+"."+i[a],name:t});return o},ADMITAD.Helpers.findTodaysDomain=function(e){function n(){var o=new XMLHttpRequest,a=i[t].domain,D="https://"+a+"/";o.open("HEAD",D,!0),o.onload=function(){setTimeout(e,0,i[t])},o.onerror=function(){++t<i.length?setTimeout(n,0):setTimeout(e,0,void 0)},o.send()}var t=0,i=ADMITAD.Helpers.generateDomains();n()},window.ADMITAD=window.ADMITAD||{},ADMITAD.Helpers.findTodaysDomain(function(e){if(window.ADMITAD.dynamic=e,window.ADMITAD.dynamic){var n=function(){return function(){return self.src?self:""}}(),t=n(),i=(/campaign_code=([^&]+)/.exec(t.src)||[])[1]||"";t.parentNode.removeChild(t);var o=document.getElementsByTagName("head")[0],a=document.createElement("script");a.src="https://www."+window.ADMITAD.dynamic.domain+"/static/" +window.ADMITAD.dynamic.name.slice(1)+window.ADMITAD.dynamic.name.slice(0,1)+".min.js?campaign_code="+i,o.appendChild(a)}});'></script> <script type="text/javascript"> ADMITAD = window.ADMITAD || {}; ADMITAD.Invoice = ADMITAD.Invoice || {}; ADMITAD.Invoice.broker = '{{broker}}'; // place to set the variable transactionChannel ADMITAD.Invoice.category = '{{category}}'; // place to set the variable transactionAction var orderedItem = []; var positions = {{transactionProducts}}; // place to set the variable transactionProducts for (i = 0; i < positions.length; ++i) { orderedItem.push({ Product: { productID: positions[i]['sku'], category: positions[i]['tariff'], price: positions[i]['price'], priceCurrency: positions[i]['priceCurrency'] }, orderQuantity: positions[i]['quantity'], additionalType: "sale" }); } ADMITAD.Invoice.referencesOrder = ADMITAD.Invoice.referencesOrder || []; ADMITAD.Invoice.referencesOrder.push({ orderNumber: '{{orderNumber}}', // place to set the variable transactionId orderedItem: orderedItem }); </script>
Do not forget to change the value of {your_campaign_code} to the one you received at the beginning of the integration.
Be sure to find orders by this orderNumber in your CRM, as it will be used for verifications in the future.
Set "TagTag conversion" as a firing trigger.
Name the trigger "TagTag conversion" and save it.
You should get the following list of tags.
Transfer of unique promo codes
Unique promo codes are promo codes that are linked to a specific publisher. Learn more about them here.
To use unique promo codes:
1. Insert the promo code value in GTM dataLayer (the structure of dataLayer can vary).
-
<script> window.dataLayer = window.dataLayer || []; dataLayer.push({ "transactionId": "sk1006", "transactionChannel": "adm", "transactionAction": "1", "transactionProducts": [{ "sku": "1354471145550", "tariff": "2", "price": "300.00", "priceCurrency": "RUB", "quantity": "2" }], "transactionPromocode": "ADMPROMO" // promo code value }); </script>
Transferring the unique promo code order information, always set up “adm” value to the deduplication parameter as the order belongs to Admitad.
Transferring a regular order (not one with a unique promo code), use the standard deduplication setting.
Example of code in CMS
2. Add a variable of a Data Layer Variable type.
3. Add the variable to the conversion tag.
Example of a code
// adding items to the order ADMITAD.Invoice.referencesOrder.push({ orderNumber: "{{orderNumber}}", // internal order ID (not more than 100 characters) discountCode: "{{promocode}}", // unique promo code orderedItem: orderedItem });
Example of a code in the tag
4. Do not forget to submit the GTM changes.
5. Make sure that the promo code is sent in the TagTag request.
Order deduplication
If you work only with Admitad Partner Network, use the default value of the deduplication parameter and skip this step.
If you work with more than one paid source, enable order deduplication on your end so that order information gets transferred in accordance with Last Paid Click:
- Inform the Admitad Partner Network tracking department which GET parameter you are going to use for deduplication. By default, the parameter is not added.
- Create a deduplication cookie with the source value. Cookie must be stored during the entire period specified in your agreement (the default period is 90 days).
- Define the value of the deduplication parameter transactionChannel from the cookie when transmitting order data in the dataLayer parameter. This way we can define which source the order belongs to. For Admitad Partner Network orders the value of the deduplication parameter must be adm. Orders with the values of other paid sources will not be created. Orders with an undefined source will be created if a user visited the website by clicking an Admitad Partner Network affiliate link on another device or browser during the cookie lifetime.
An example of the code where the cookie is used to store the click source
-
// name of the cookie that stores the source // change if you have another name var cookie_name = 'deduplication_cookie'; // cookie lifetime var days_to_store = 90; // expected deduplication_cookie value for Admitad var deduplication_cookie_value = 'admitad'; // name of GET parameter for deduplication // change if you have another name var channel_name = 'deduplication_channel'; // a function to get the source from the GET parameter getSourceParamFromUri = function() { var pattern = channel_name + '=([^&]+)'; var re = new RegExp(pattern); return (re.exec(document.location.search) || [])[1] || ''; }; // a function to get the source from the cookie named cookie_name getSourceCookie = function() { var matches = document.cookie.match(new RegExp( "(?:^|; )" + cookie_name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" )); return matches ? decodeURIComponent(matches[1]) : undefined; }; // a function to set the source in the cookie named cookie_name setSourceCookie = function() { var param = getSourceParamFromUri(); if (!param) { return; } var period = days_to_store * 60 * 60 * 24 * 1000; // in seconds var expiresDate = new Date((period) + +new Date); var cookieString = cookie_name + '=' + param + '; path=/; expires=' + expiresDate.toGMTString(); document.cookie = cookieString; document.cookie = cookieString + '; domain=.' + location.host; }; // set cookie setSourceCookie(); // define a channel for Admitad if (!getSourceCookie(cookie_name)) { dataLayer.push({ "transactionChannel": 'na' }); } else if (getSourceCookie(cookie_name) != deduplication_cookie_value) { dataLayer.push({ "transactionChannel": getSourceCookie(cookie_name) }); } else { dataLayer.push({ "transactionChannel": 'adm' }); }
Cross-device tracking
Cross-device tracking allows publishers to get rewards for orders in cases where users employ multiple devices. This boosts a program's appeal for publishers who, for instance, attract mobile traffic.
This function is enabled by default. When a user visits an advertiser's site, we put together a unique anonymous profile for them. When an order is made, we collate the profile data and record the order if admitad_uid is present. The function works best when deduplication is enabled. To help Admitad Partner Network identify a user precisely, you can indicate the user's unique ID explicitly in a dataLayer object. You might use the user's email address or login if they've signed up on the site. The user's unique ID has priority over the anonymous profile. If you specify the accountId, the tracking code won't transmit info about the anonymous profile in the request that gets sent to Admitad Partner Network; your data is used instead.
When using GTM, add the user's ID to a dataLayer object.
dataLayer.push({
"transactionCustomer": "customer@email.ru"; // user e-mail
});
Admitad Partner Network does not store the value of this parameter and does not transmit it unsecure. The value of the variable is irreversibly hashed with Sha256 + salt and then is used by Admitad Partner Network as a unique identifier of the user’s orders.
Add a new variableaccountID and link with a variable of thetransactionCustomer data layer.
Paste the string below to the “TagTag conversion” tag:
ADMITAD.Invoice.accountId = '{{accountId}}'; // place to set the variable transactionCustomer
Save the tag “TagTag conversion”.
Then add the same string to the tag “TagTag common” and save it, too.
Tracking testing
Make sure that you have set up the tracking code correctly. Note that if you have a mobile version of the website, it should also be integrated.
After that contact the Admitad Partner Network tracking department and request a test link.
Test procedure
If your program has several actions (e.g. “Registration” and “Paid order”), you need to test each of them.
1. Follow the test link to your website. Check if the address bar contains all required GET parameters and UTM parameters.
2. Perform an action on the website. For example, buy something.
3. If the tracking is set correctly, the action will appear in the Admitad Partner Network statistics (account — Reports — on actions).
4. Check if the action name, action ID, and order amount are the same as in the Admitad Partner Network reports.
In case you run the tests successfully, inform the Admitad Partner Network specialists about it. They will prepare the program for launch.
Problems that can arise during testing
If the action has not appeared in the statistics, probably, you made a mistake during tracking code installation and setting it up:
Problem | How to fix it |
The script does not work. No requests from the script on the Network browser tab. | The script is installed incorrectly. Follow the instructions of the section Installation of the tracking code in Google Tag Manager. |
The script does not work. There are errors in the browser console. | Follow the instructions of the section Installation of the tracking code in Google Tag Manager. Check the syntax of JavaScript on the thank you page |
The script is triggered. There are no errors in the browser console. The order has not appeared in the statistics. | The value of the campaign_code parameter is invalid or missing. Make sure that the value of campaign_code is the same that the Admitad Partner Network specialist sent you at the beginning of the integration. |
The script is triggered. There are no errors in the browser console. The value of the campaign_code parameter is correct. The order has not appeared in the statistics. | To identify the error, go to the request log (Tools — Request log). The error text is specified in the Result field. Correct the error and retest. Guide on the Request log is available here. |
The script is triggered. There are no errors in the browser console. The value of the campaign_code parameter is correct. No errors in the Request log section. The order has not appeared in the statistics. | There is a log delay on the Admitad Partner Network side, wait an hour and then check again. |
The script is triggered. There are no errors in the browser console. The value of the campaign_code parameter is correct. No errors in the Request log section. The order has not appeared in the statistics within an hour. | Ask the Admitad Partner Network specialist for help. |