Skip to main content
GTM Mirror Overview

This is a complete guide on configuring conversion points and data points using our GTM Mirror functionality

D
Written by Dan Bier
Updated yesterday

Please note this is the latest version of our Conversion Package so you may be using an older version. If you are unsure please contact the support team.

What is GTM Mirroring?

GTM Mirroring is one of a few ways to get data into Webtrends Optimize, as standard, for all experiences you build. For a full guide of options, see: Global metric capture - a complete guide.

GTM Mirroring is Webtrends Optimize listening for events that take place in Google Tag Manager, and sending those to Webtrends Optimize as they happen on the page. As events are pushed into the datalayer, we will also send them to Optimize.

The conversion points defined in a preinit script are global, meaning they are sent to WTO for all the tests a visitor is in when the conversion is triggered. These conversion points are then visible in a test's report within the WTO UI.

Where can I find the GTM Mirroring script?

The GTM Mirror config is housed in the preinit script of your tag config.

Structure of GTM Mirroring event

Basic structure

The basic template for the GTM Mirror object is below.

WT.GTMEventsToMirror = {
/*
gtm_event_name: [
{
name: "wto_event_name",
ifCondition: function(ev) {
return othercheck === "happy";
},
collectData: function(ev) {
return {
customdata1: value1,
customdata2: value2
};
}
},
]
*/
};

Whenever an event is pushed to the dataLayer object, we check if it is listed in the GTMEventsToMirror object and if the conditions match, it will be sent to Optimize.

GTM events are stored as properties in the WT.GTMEventsToMirror object, with each event mapped to an array, as shown below.

WT.GTMEventsToMirror = {
form_submit_success: [
// logic for conversion here
],
add_to_cart: [
// logic for conversion here
],
};

Here, we are listening for two events. You define the name of the conversion point using the name key and defining a value.

Available options

The options available to identify and capture your metric include:

Name

stringData type

Explanation

name
(required)

String

The name of the event as captured in WTO

ifCondition

(optional)

Function

Must return truthy/falsey value

A javascript condition check

collectData

(optional)

Function

Must return JSON key:value object

Attaches Custom Data to the metric, e.g. adding Revenue and Units to a Purchase event.

ifCondition

Below is an example for the ifCondition method.

ifCondition: function(ev) { 
return ev.formName === "enquiry";
}

The ifCondition function receieves the event object as passed into the dataLayer.push call. In this example, the script checks whether an additional event parameter named formName has a value of 'enquiry'. If the condition is met, the conversion point is sent with the defined name.

collectData

Below is an example for the collectData method.

collectData: function(ev) {
return {
name: ev.name,
model: ev.model
};
}

In the above example, name and model are being collected from event parameters.

Data points need to be defined in the automated tracking section of your WTO account, like below, before the data will be stored.

If the collectData is numeric, it can be included in reports and presented as non-binomial metrics, as shown below.

If the collectData is text then this will be available to download as raw data under bespoke extract.

Did this answer your question?