Skip to main content
Skip table of contents

Webgains Default Tracking Implementation

Here you can find information about integrating as an advertiser with the default Webgains tracking script, which consists of two pieces of code that need adding to your site that allow us to track conversions generated by Webgains affiliates.

Prior to this, please ensure you have your Program ID, and have been contacted by your Webgains Integration Manager regarding the set-up.

To comply with the regulations governing cookies under the GDPR and the ePrivacy Directive you must receive users' consent before you use any marketing cookies, including the landing page script.

Step 1 - The Landing Page Script

The Landing Page Script must be placed on every page of your website. It is used to record our WGU value to track where the request has originated from (which campaign) so we can track sales to that publisher campaign for that session.

The landing page script is copy & paste script (below), replacing “XXXXXX” in line 9 with your unique program ID. If you are unsure of your program ID please speak to your Integration Manager. This script needs to be added to every page of your website.

CODE
<script>
(function(src) {
var o = 'ITCLKQ';
window[o] = window[o] || function() {(window[o].q=window[o].q||[]).push(arguments)};
window[o].l = 1 * new Date();
var s = document.createElement('script');
var f = document.getElementsByTagName('script')[0];
s.async = 1;s.src = src;f.parentNode.insertBefore(s,f);
})('https://analytics.webgains.io/XXXXXX/main.min.js');
ITCLKQ('set', 'internal.api', true);
ITCLKQ('set', 'internal.cookie', true);
ITCLKQ('click');
</script>

We also use this script to activate our additional Publisher Services, should you wish to work with any.

More information on this can be found here, and the services can be activated within your account under the Tracking page.

Step 2 - The Conversion Script

This script must be added at the bottom of the order confirmation page of your site. That is, the page a customer reaches after successfully completing a sale.

If the page is developed in HTML, then please make sure the code lies between the <BODY></BODY> tags.

It is important that our tracking code is present on the order confirmation page at all times as we have a "cookieless" tracking method which we will invoke, should our servers find no affiliate cookies on the user's browser. Like all our tracking, if we don't find any "cookieless" or traditional cookies, we will not record a sale.

The tracking code consists of various elements that you report back to us. Depending on the type of commission you have opted for, some of the variables are omitted accordingly.

The default conversion script is as below, replacing “XXXXXX” in lines 2 and 3 with your unique program ID and commission event ID (respectively). If you are unsure of your program and event IDs, please speak to your Integration Manager.

CODE
<script>
var programid = 'XXXXXX';
var eventid = 'XXXXXXX';
(function(src) {
var o = 'ITCVRQ';
window[o] = window[o] || function() {(window[o].q=window[o].q||[]).push(arguments)};
window[o].l = 1 * new Date();
var s = document.createElement('script');
var f = document.getElementsByTagName('script')[0];
s.async = 1;s.src = src;f.parentNode.insertBefore(s,f);
})('https://analytics.webgains.io/'+programid+'/main.min.js');
ITCVRQ('set', 'trk.programId', programid );
ITCVRQ('set', 'cvr', {
value: '',
currency: '',
language: '',
eventId: eventid,
orderReference: '',
comment: '',
multiple: '',
checksum: '',
items: '',
customerType: '',
customerId:'',
voucherId: '',
location: document.location.href || 'https://website.com'
});
ITCVRQ('conversion');
</script>

We will now take you through all the parameters that need to be modified within the Conversion Script.

Step 3 - Conversion Script Values

Program ID

As mentioned above, this value should be your static unique Program ID, provided by Webgains.

Event ID

As mentioned above, this value should be your static unique Event ID, provided by Webgains.

If it's the case that you have multiple events (i.e. for advanced commission schemes that are currently not possible via our Smart Commissions tool), you will need to pass them according to your chosen setup. Your Integration Manager will help guide on this.

Value

The total order sale value needs to be stored in the 'value' variable.

If your webpage does not use the sales value, then this value may be set to "0". Please make sure to use "." for decimal places.

The value you send us here will be used to calculate percentage-based commissions. Therefore, please check if you want to enter the value with or without VAT or delivery costs. Discounts from promotions and/or voucher codes need to be subtracted from this total order value.

Currency

This value needs to match the Checkout currency of the sale. We then convert to the currency your Webgains program is set up as.
This is crucial to ensure that your values and commissions are calculated accurately.

Please find a full list of currencies we accept here.

Language

The language value should mirror the language displayed on your website.
We accept the following format: 'en_EN'

Order Reference

Please ensure that the same unique order number that is presented to the customer on their order invoice is also passed into this variable. This will be the reference displayed for the transaction in your Webgains reporting, and so you should ensure it matches the reference in your internal shop system records so you can locate the sale.

Customer Type

This is an optional value however one we recommend, as it allows the use of our Smart Commissioning tool so you can automatically set different commission schemes based on if the customer is tracked as New or Existing.

The values we accept are “New” and “Existing”, which you should populate based on if the customer is new or returning. We do also accept Custom customer types (e.g. Subscription) which must be defined by you. Please speak to your Integration Manager should you require any support with setting up Custom values.

Location

You will need to change ‘https://website.com/’ to be the URL for your website.

Comment, Multiple, Checksum, Customer ID

All of these values can be left blank, there is no need for you to action anything here.

Items

Optional, though highly recommended in order to fully utilise Webgains product reporting, and our Smart Commissioning tool which allows you to set different commission schemes based on the tracked product/s a customer has purchased.

This variable consists of multiple properties that let us know the item information: Event ID, Product price, Product name, Product ID and Voucher code.

Each individual item in the string, including separate instances of the same item, must be separated by the pipe symbol (|) and each property of each item must be separated by two colons (::).

The specific order of these properties must be maintained. Guidance on the JSON array for item tracking is below.

Setting up the Items Tracking:

To create the wgItems JSON array from an array of products, you can follow these steps:

  1. Define the Array of Products: Make sure you have an array of products where each product has properties such as name, price, and id.

  2. Initialize the wgItems Array: Create an empty array to store the transformed product objects.

  3. Iterate Over the Products Array: Use a loop to iterate through each product in the products array.

  4. Transform Each Product: For each product, create an object with the required properties (name, price, voucher, event, code) and add it to the wgItems array.

Here is a sample code snippet to illustrate the process:

JS
// Sample array of products
var products = [
    { name: 'Red Dress', price: 9.99, id: '499912' },
    { name: 'Blue Dress', price: 7.99, id: '499942' }
];

// Initialize the wgItems array
var wgItems = [];

// Iterate over each product in the products array
for (var product of products) {
    // Create an object for each product with the required properties
    var item = {
        name: product.name,
        price: String(product.price),  // Convert price to string
        voucher: '',
        event: '',
        code: product.id
    };
    
    // Add the transformed object to the wgItems array
    wgItems.push(item);
}
Explanation:
  1. Products Array:

    • This array contains objects where each object represents a product with properties such as name, price, and id.

  2. wgItems Array:

    • This is the array that will store the transformed product data in the required JSON format.

  3. Loop Through Products:

    • The for...of loop iterates through each product in the products array.

  4. Create Transformed Object:

    • For each product, a new object is created with properties name, price, voucher, event, and code.

    • The price is converted to a string using String(product.price).

  5. Add to wgItems:

    • The newly created object is added to the wgItems array using push.

Below are full details on formats and restrictions for each item property.

Property

Requirement

Description

Event ID

Compulsory

This represents the type of commission (that has already been set up on the Webgains system) to be applied.

Product Price

Compulsory

The price of the item. Please check if you need to exclude any tax or shipping amounts, and be sure to deduct any discounted amounts from the Item Value and the total Order Value. These two values should match in order for us to accurately calculate commission.

Please omit any currency symbols (£).

Product Name

Optional

The name of the item (max 255 characters).

Product ID

Optional

Product Code/Unique Reference for the product. This is often your product SKU. Max 100 characters.

If you are using our Smart Commission tool, please ensure this ID matches the Product ID you provide in your Product Feed.

Voucher Code

Optional

The voucher code for the specific product (or group of products), should any be used in the transaction.

Please ensure that the voucher discount amount is deducted from the Item Value and total Order Value.

Voucher ID

Voucher tracking is optional however allows for voucher code reporting, as well as additional voucher tracking features whereby if set-up correctly, and a voucher code added to the platform is set to an Exclusive publisher, only that publisher will be attributed sales for tracked usage of the voucher code.

Although voucher codes can be applied to particular products in the items array, a single voucher code can be applied to the entire transaction by using the 'voucherId' variable.

If a voucher code has been set in voucherId, any items within items without individual voucher codes assigned will have the voucherId applied to them.

JavaScript errors detected

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

If this problem persists, please contact our support.