hello@newnorth.nl+31 (0) 85 401 31 62
/Journal

Webgains GTM tag template

TemplateGTM2026.04.04
Freek Kampen
Freek KampenCo-founder, New North Digital

Webgains affiliate tracking in Google Tag Manager, with click tracking and conversion tracking including item-level product data.

What it does

The Webgains template brings Webgains affiliate tracking into GTM with two action types: Click Tracking on all pages, and Conversion Tracking on the order confirmation.

It uses the Webgains command queue pattern, ITCLKQ for clicks and ITCVRQ for conversions, and loads the program-specific main.min.js script.

Features

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

Installation

  • In your GTM workspace, go to Templates, then Tag Templates, then Search Gallery.
  • Search for Webgains and add the template.
  • Create two tags: one for Click Tracking and one for Conversion.

Configuration

Step 1. Deploy the Click Tracking tag. Set Action Type to Click Tracking and enter your Program ID. This tag has to fire on every page to capture affiliate clicks from Webgains publishers. It loads main.min.js and initialises click detection.

Step 2. Set up order data variables. Create Data Layer Variables for ecommerce.transaction_id (Order Reference), ecommerce.value, ecommerce.currency, ecommerce.items, and a variable for your voucher code if you use one. Your Webgains account manager provides the Event ID, which is usually a static value you can hard-code.

Step 3. Deploy the Conversion tag. Create a second tag with Action Type Conversion and map each field. On firing it initialises the ITCVRQ queue, pushes program ID, order reference, value, currency, event ID, voucher code, items and language, then calls conversion().

Step 4. Sequence the tags. Use Tag Sequencing so main.min.js has loaded before the Conversion tag fires. On the confirmation page, set Click Tracking as the setup tag for Conversion.

dataLayer snippet

Push this 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. The URL is built as https://analytics.webgains.io/{programId}/main.min.js, and an invalid ID gives a 404. Check the Network tab.

Conversions missing from the dashboard. Confirm the Event ID matches the one configured in your Webgains program. A wrong Event ID means the conversion fires but Webgains cannot classify it.

Duplicate conversions. If the confirmation page can be reloaded, the tag fires again. Use a dataLayer flag or a first-party cookie so purchase only pushes once per session.

Voucher code not tracked. Make sure the variable resolves to the actual code. With no code used, the field should be empty rather than undefined or null.

Items missing from the conversion. The Items variable has to return an array of objects. Check in Preview that it resolves on the confirmation page. If it returns undefined, your dataLayer push may lack the items array or the variable path is wrong.

Ad blocker interference. The analytics.webgains.io domain can be blocked. Client-side affiliate tracking is inherently exposed to this. Server-side GTM can reduce the loss if it is significant.

Support

  • Webgains Knowledge Hub: https://knowledgehub.webgains.com/home/webgains-default-tracking-guide
  • Webgains Partner Portal: https://www.webgains.com/
  • GTM Community Template Gallery: search Webgains for the listing and version history
  • GTM Help Center: https://support.google.com/tagmanager/

Want to talk about this?

Let's talk data.

Tell us about your stack, your goals, the data you wish you had.

Takes 1 minute