Webgains Container for Publisher Scripts - Supported by Neory.
To work with certain technology publishers - especially for retargeting and onsite solutions - you may need to add the publisher scripts to your website. This often involved adding dynamic values from your shop, such as product ids and names, within those scripts.
Webgains makes this easier: Supported by Neory, our solution means advertisers just need to add the Webgains Container tag once, and then will be able to manage all the publisher scripts they choose to work with without any additional code needed.
This guide explains how to set it up the Webgains Container for Publisher Scripts into your website.
Important: You will receive your Container ID from your Webgains Integration Manager. This ID is required for all integrations.
1. General Guidelines
-
Always define
window.ntmDatabefore including the General Tag script. -
Include all required fields for proper integration.
-
Avoid using iFrames, as tracking may fail inside iFrames.
-
Ensure that selected publishers are listed in your CMP if required.
-
Include the General Tag on all pages, after defining
window.ntmData.
2. General Tag
The General Tag must be included on all pages. It initializes the container and ensures all tracking data is sent correctly.
<script>
(function(window, document, tagName, dataLayerName, containerId) {
window[dataLayerName] = window[dataLayerName] || [];
window[dataLayerName].push({
'event': 'ntmInit',
't': new Date().getTime()
});
var firstScript = document.getElementsByTagName(tagName)[0];
var script = document.createElement(tagName);
var dataParam = dataLayerName !== 'ntmData' ? '&ntmData=' + dataLayerName : '';
script.async = true;
script.src = 'http' + (document.location.protocol === 'https:' ? 's' : '') +
'://tm.container.webgains.link/tm/a/container/init/' +
containerId + '.js?' + dataParam +
'&rnd=' + Math.floor(Math.random() * 100000000);
firstScript.parentNode.insertBefore(script, firstScript);
})(window, document, 'script', 'ntmData', 'YOUR_CONTAINER_ID');
</script>
Notes:
-
Replace
YOUR_CONTAINER_IDwith your actual Container ID. -
Must appear after all
window.ntmData.push({...})calls on the page.
3. GDPR / TCF 2.0 Compliance
All tags support TCF 2.0 for GDPR compliance.
|
Parameter |
Required/Recommended |
Description |
|---|---|---|
|
|
Required |
|
|
|
Recommended |
IAB TCF 2.x consent string (required if |
|
|
Required |
Page type: |
Example GDPR Setup:
<script>
window.ntmData = window.ntmData || [];
window.ntmData.push({
gdpr: "-1",
gdprConsent: "XXXXXXXXXXXXXXXXXXXX",
pageType: "generic"
});
</script>
-
If no CMP is in use, set
gdpr = -1and omitgdprConsent.
4. Page-Specific Tags
All page-specific tags use the same pattern, which can be used as a template for any page type:
<script>
window.ntmData = window.ntmData || [];
window.ntmData.push({
gdpr: "-1", // GDPR status: -1 = no CMP, 0 = not applicable, 1 = applies
gdprConsent: "", // TCF 2.x consent string if applicable
pageType: "PAGE_TYPE", // Replace with the type of page: homepage, generic, category, product, searchresult, wishlist, basket, order
// Page-specific fields (add as needed)
categoryId: "CATEGORY_ID", // Required for category/product pages
categoryName: "CATEGORY_NAME", // Optional for category pages
productId: "PRODUCT_ID", // Required for product/order pages
productPrice: "PRODUCT_PRICE", // Recommended for product/order pages
productName: "PRODUCT_NAME", // Recommended for product/order pages
pageName: "PAGE_NAME", // Optional for generic pages
searchTerm: "SEARCH_TERM", // Required for searchresult pages
products: [ // Required for wishlist, basket, order pages
{ id: "PRODUCT_ID", qty: QTY, price: "PRICE", name: "PRODUCT_NAME" }
],
transactionId: "ORDER_ID", // Required for order pages
orderValue: "ORDER_VALUE" // Required for order pages
});
</script>
<!-- General Tag -->
<script>/* Insert General Tag script here */</script>
How to Use This Pattern
-
Set
pageTypeaccording to the type of page. -
Include page-specific fields depending on the page type:
|
Page Type |
Required Fields |
Optional Fields |
|---|---|---|
|
Homepage |
|
|
|
Generic |
|
|
|
Category |
|
|
|
Product |
|
|
|
Search Result |
|
|
|
Wishlist |
|
|
|
Basket |
|
|
|
Order |
|
|
-
Replace placeholders like
PAGE_TYPE,CATEGORY_ID,PRODUCT_ID,PRODUCT_NAME,ORDER_IDetc., with your actual site values. -
Keep the General Tag script identical for all pages.
4.1 Homepage Tag (Mandatory)
Tracks homepage visits.
|
Field |
Required/Recommended |
Notes |
|---|---|---|
|
|
Required |
See GDPR section |
|
|
Recommended |
Include if GDPR applies |
|
|
Required |
Must be |
Example:
<script>
window.ntmData = window.ntmData || [];
window.ntmData.push({
gdpr: "-1",
gdprConsent: "XXXXXXXXXXXXXXXXXXXX",
pageType: "homepage"
});
</script>
<!-- General Tag -->
<script>/* Insert General Tag script here */</script>
4.2 Generic Page Tag (Optional)
Use for pages without a dedicated tag.
|
Field |
Required/Recommended |
Notes |
|---|---|---|
|
|
Required |
Must be |
|
|
Recommended |
Short identifier, e.g., |
Example:
<script>
window.ntmData = window.ntmData || [];
window.ntmData.push({
gdpr: "-1",
gdprConsent: "",
pageType:"generic",
pageName:"contact"
});
</script>
<!-- General Tag -->
<script>/* Insert General Tag script here */</script>
4.3 Category Page Tag (Optional, Recommended)
Tracks user interest in categories.
|
Field |
Required/Recommended |
Notes |
|---|---|---|
|
|
Required |
Must be |
|
|
Required |
Must match catalog ID |
|
|
Recommended |
Should match catalog name |
Example:
<script>
window.ntmData = window.ntmData || [];
window.ntmData.push({
gdpr: "-1",
gdprConsent: "XXXXXXXXXXXXXXXXXXXX",
pageType: "category",
categoryId: "cat123",
categoryName: "Laptops"
});
</script>
<!-- General Tag -->
<script>/* Insert General Tag script here */</script>
4.4 Product Detail Page Tag (Recommended)
Tracks viewed product details.
|
Field |
Required/Recommended |
Notes |
|---|---|---|
|
|
Required |
Must be |
|
|
Required |
Must match catalog |
|
|
Required |
Unique product ID |
|
|
Recommended |
Numeric, dot decimal, no thousand separators |
|
|
Recommended |
Short product name |
Example:
<script>
window.ntmData = window.ntmData || [];
window.ntmData.push({
gdpr: "-1",
gdprConsent: "XXXXXXXXXXXXXXXXXXXX",
pageType: "product",
categoryId: "cat123",
productId: "prod456",
productPrice: "1299.99",
productName: "SuperLaptop 15 Pro"
});
</script>
<!-- General Tag -->
<script>/* Insert General Tag script here */</script>
4.5 Search Results Page Tag (Optional, Recommended)
Tracks products from search results.
|
Field |
Required/Recommended |
Notes |
|---|---|---|
|
|
Required |
Must be |
|
|
Required |
Comma-separated if multiple terms |
|
|
Required |
Array of |
Example:
<script>
window.ntmData = window.ntmData || [];
window.ntmData.push({
gdpr: "-1",
gdprConsent: "XXXXXXXXXXXXXXXXXXXX",
pageType: "searchresult",
searchTerm: "gaming laptop",
products: [
{ id: "prod456" },
{ id: "prod789" }
]
});
</script>
<!-- General Tag -->
<script>/* Insert General Tag script here */</script>
4.6 Wishlist Page Tag (Optional, Recommended)
Tracks products in user wishlists.
|
Field |
Required/Recommended |
Notes |
|---|---|---|
|
|
Required |
Must be |
|
|
Required |
Array of |
Example:
<script>
window.ntmData = window.ntmData || [];
window.ntmData.push({
gdpr: "-1",
gdprConsent: "XXXXXXXXXXXXXXXXXXXX",
pageType: "wishlist",
products: [
{ id: "prod456" },
{ id: "prod789" }
]
});
</script>
<!-- General Tag -->
<script>/* Insert General Tag script here */</script>
4.7 Shopping Basket Tag (Optional, Recommended)
Tracks products in the shopping cart.
|
Field |
Required/Recommended |
Notes |
|---|---|---|
|
|
Required |
Must be |
|
|
Required |
Array of |
Example:
<script>
window.ntmData = window.ntmData || [];
window.ntmData.push({
gdpr: "-1",
gdprConsent: "XXXXXXXXXXXXXXXXXXXX",
pageType: "basket",
products: [
{ id: "prod456", qty: 1, price: "1299.99", name: "SuperLaptop 15 Pro" },
{ id: "prod789", qty: 2, price: "499.99", name: "Wireless Mouse" }
]
});
</script>
<!-- General Tag -->
<script>/* Insert General Tag script here */</script>
4.8 Order Confirmation Page Tag (Mandatory)
Tracks completed orders.
|
Field |
Required/Recommended |
Notes |
|---|---|---|
|
|
Required |
Must be |
|
|
Required |
Unique order number |
|
|
Required |
Numeric, dot decimal |
|
|
Required |
Array of |
Example:
<script>
window.ntmData = window.ntmData || [];
window.ntmData.push({
gdpr: "-1",
gdprConsent: "XXXXXXXXXXXXXXXXXXXX",
pageType: "order",
transactionId: "order123456",
orderValue: "2299.97",
products: [
{ id: "prod456", qty: 1, price: "1299.99", name: "SuperLaptop 15 Pro" },
{ id: "prod789", qty: 2, price: "499.99", name: "Wireless Mouse" }
]
});
</script>
<!-- General Tag -->
<script>/* Insert General Tag script here */</script>
5. Key Best Practices
-
Always define
window.ntmDatabefore the General Tag. -
Include GDPR fields if your site uses a CMP.
-
Use page-specific tags only where needed; the Generic Tag can fill gaps.
-
Match IDs, category names, and product names exactly to your catalog.
-
Test tracking after deployment to verify that data is sent correctly.
Please note that this solution is separate to The Webgains Tag, which can be managed within the Webgains platform. Please speak to your Webgains contact/account manager for more information on the solutions.