Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test data layer variables in Google Tag Manager?

In Google Tag Manager, I have some data layer variables set up. How can I test that the data is coming in through these variables as I expect? So, I want to verify that the data is getting collected in the dataLayer object (which can be done with Firebug, etc), but more importantly, I want to know that GTM is receiving the data, that the macros and rules are executing as expected, etc.

So, on the website, I have some code like this:

dataLayer = [];

dataLayer.push({
    'city': 'city name',
    'state': 'state name',
    'subtotalCost': 'subtotal $',
    'salesTax': 'sales tax $'
});

And then after this, I have the GTM code that loads gtm.js. This seems to be implemented correctly, however, I want to test that the values for the data layer variables are coming through as expected. Where can I check this at?

like image 716
matthewpavkov Avatar asked Nov 18 '13 21:11

matthewpavkov


People also ask

How do I use data layer variable in Google Tag Manager?

Set up the data layer variableClick Variables. Under User-Defined Variables, click New. Click Variable Configuration and select Data Layer Variable as the variable type. In the Data Layer Variable Name field, enter the key exactly as it was written in the code (e.g. bookTitle, not book title.)

How do you test data layers?

Method #3: Using Chrome Developer Tools > Console A third way to find your data layer information is using the console tab in developer tools. Simply type “dataLayer” into the console, and voila, there's your data layer. Click the down arrow next to the data layer array, and you can see the different objects inside.


1 Answers

The console is your friend. What I would do is type dataLayer into the console after dataLayer.push, then click on the last object in the array and you'll see your values.

For instance, I put the dataLayer.push on an onclick event and ran dataLayer and was able to see this come through. Granted they are static values, but you get the idea.

enter image description here

UPDATE:

Google Tag Manager has updated their debugger, allowing you to see both Names or Values being passed into GTM.

enter image description here

like image 87
Blexy Avatar answered Oct 06 '22 01:10

Blexy