How To Set-up Webgains With Google Tag Manager
Mark Slocock / +Mark / February 7, 2017

We recently had to implement Webgains tracking for a client, we were using Google Tag Manager and Enhanced Ecommerce Google Analytics.  Simple we thought, as all the data required for order tracking is in the data-layer for GA EE, however it was not straight forward and there was a real lack of information online, so having found the solution we wanted to share it.

Implementing Webgains requires creating a product feed and implementing order tracking, this guide focuses on the order tracking.  We focus on Magento, however this guide will work on any platform. If you use Magento we recommend Data Feed Manager from WYOMIND to create product feeds

So first there are some requirements, this guide assumes the following:

  1. Have implemented the Enhanced Ecommerce data-layer for Google Analytics
  2. Use Google Tag Manager with 3 variables setup:
  • Order ID set-up as a variable called "ee transaction id" 
  • Order Revenue set-up as a variable called "ee transaction revenue"
  • Products ordered set-up as a variable called "ee transaction products array"

How to implement webgains order tracking in GTM

  1. Setup the first variable, a constant, name it "wgEventID", the value will be provided by Webgains webgains eventid
  2. Setup the second variable, a constant, name it "wgProgramID", the value will be provided by Webgainswebgains programid
  3. Setup the third variable, custom javascript, we report revenue including VAT to GA so we need to remove this.  We also already have a variable already defined called "ee transaction revenue" which we are referencing essentially we're taking the revenue removing 20% VAT and using that to post to Webgainswebgains revenue
  4.  Setup the fourth variable, again custom javascript, this is the trickiest one to get right, essentially we're looping through the products in the data-layer and building the Items string required for the trackingwebgains items
  5. Set-up the trigger, its vital that your trigger is set to Page View - Window Loaded and only fires on your order confirmation or success page, for Magento (1 & 2) the URL is /checkout/onepage/success/webgains trigger
  6. Set-up the tag, a custom HTML tag, this is the tracking script you'll receive from Webgains (ask for the non open tag version)webgains tag