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
ITCLKQcommand queue to set API and cookie configuration, then callsclick() - Conversion tracking uses the
ITCVRQcommand queue with full order data and callsconversion() - 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
- In your GTM workspace, go to Templates > Tag Templates > Search Gallery.
- Search for “Webgains” and add the template.
- 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 Referenceecommerce.value— Order Valueecommerce.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:
- Initializes the
ITCVRQcommand queue - Pushes the program ID, order reference, value, currency, event ID, voucher code, items, and language
- 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
- 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 template listing and version history
- GTM Help Center: https://support.google.com/tagmanager/