Webgains GTM tag template

6 minutes read

The Webgains tag template brings Webgains affiliate tracking into Google Tag Manager with two action types: Click Tracking (all pages) and Conversion Tracking (order confirmation). It uses Webgains’ command queue pattern (ITCLKQ for clicks, ITCVRQ for conversions) and loads the program-specific main.min.js script, so you get full affiliate attribution without managing custom HTML tags.

Features

  • Two action types: Click Tracking and Conversion Tracking in one template
  • Click tracking uses the ITCLKQ command queue to set API and cookie configuration, then calls click()
  • Conversion tracking uses the ITCVRQ command queue with full order data and calls conversion()
  • Supports item-level product data for accurate commission calculation
  • Voucher code field for tracking promotional conversions
  • Loads the program-specific script from https://analytics.webgains.io/{programId}/main.min.js

Installation

  1. In your GTM workspace, go to Templates > Tag Templates > Search Gallery.
  2. Search for “Webgains” and add the template.
  3. Create two tags: one for Click Tracking and one for Conversion.

Field Reference

Click Tracking action

Field Type Required Description
Action Type Dropdown Yes Select “Click Tracking”.
Program ID Text Yes Your Webgains program ID. Used to load the correct tracking script and configure the click tracker.

The click tracking tag initializes the ITCLKQ command queue, sets internal.api and internal.cookie configuration, and calls click() to register the affiliate click.

Conversion action

Field Type Required Description
Action Type Dropdown Yes Select “Conversion”.
Program ID Text Yes Your Webgains program ID.
Order Reference Text Yes Unique order/transaction identifier.
Order Value Text Yes Total order value.
Currency Text Yes ISO 4217 currency code (e.g., EUR, GBP, USD).
Event ID Text Yes The Webgains event ID for this conversion type (provided by your Webgains account manager).
Voucher Code Text No Promotional/discount code used in the order, if any.
Items Variable Variable Yes A GTM variable returning an array of item objects for line-item reporting.
Language Text No Language code for the conversion context (e.g., en_EN, nl_NL).

Configuration Guide

Step 1: Deploy the Click Tracking tag

Create a tag with Action Type set to “Click Tracking” and enter your Program ID. This tag must fire on every page to capture affiliate clicks from Webgains publishers. It loads https://analytics.webgains.io/{programId}/main.min.js and initializes the click detection.

Step 2: Set up order data variables

Create Data Layer Variables for:

  • ecommerce.transaction_id — Order Reference
  • ecommerce.value — Order Value
  • ecommerce.currency — Currency
  • A variable for your Voucher Code (if applicable)
  • ecommerce.items — Array of product objects

Your Webgains account manager will provide the Event ID. This is typically a static value you can hard-code in the tag field.

Step 3: Deploy the Conversion tag

Create a second tag with Action Type “Conversion”. Map each field to the variables above. When this tag fires, it:

  1. Initializes the ITCVRQ command queue
  2. Pushes the program ID, order reference, value, currency, event ID, voucher code, items, and language
  3. Calls conversion() to send the data to Webgains

Step 4: Tag sequencing (recommended)

Use GTM’s Tag Sequencing feature to ensure the Click Tracking tag (or at least the main.min.js script) has loaded before the Conversion tag fires. On the order confirmation page, set the Click Tracking tag as a setup tag for the Conversion tag.

Triggers and Setup

Tag Trigger Type Condition
Click Tracking All Pages (Page View) Fires on every page load
Conversion Custom Event or Page View Fires on purchase event or thank-you page URL

dataLayer snippet

Push the following on your order confirmation page:

dataLayer.push({
  event: 'purchase',
  ecommerce: {
    transaction_id: 'WG-2024-54321',
    value: 89.90,
    currency: 'EUR',
    items: [
      {
        item_id: 'SHOE-BLK-42',
        item_name: 'Running Shoe Black',
        price: 89.90,
        quantity: 1
      }
    ]
  },
  voucher_code: 'SUMMER10'
});

Troubleshooting

Click tracking script not loading

Verify the Program ID is correct. The script URL is constructed as https://analytics.webgains.io/{programId}/main.min.js — an invalid program ID results in a 404. Check the Network tab in DevTools.

Conversions not appearing in Webgains dashboard

Confirm that the Event ID matches the one configured in your Webgains program. An incorrect Event ID means the conversion fires but Webgains cannot classify it.

Duplicate conversions

If your confirmation page can be reloaded or revisited, the conversion tag will fire again. Implement a dataLayer flag or GTM variable that only pushes the purchase event once per session. Alternatively, use a 1st-party cookie to deduplicate.

Voucher code not tracked

Make sure your Voucher Code variable resolves to the actual code string. If the customer did not use a code, the field should be empty (not undefined or null).

Items data missing from conversion

The Items Variable must return an array of objects. Check in GTM Preview that the variable resolves correctly on the confirmation page. If it returns undefined, your dataLayer push may be missing the items array or the variable path is misconfigured.

Ad blocker interference

The analytics.webgains.io domain may be blocked by ad blockers. Client-side affiliate tracking is inherently subject to this. Server-side GTM can mitigate this if conversion loss is significant.

Support

Profielfoto Freek Kampen

By Freek Kampen

Data & Analytics consultant and co-owner of New North Digital. With a background in online advertising, I solve tracking and data issues for entrepreneurs and agencies.

Looking for growth? ▸ Set your New North ▸