0
votes

As my heading suggest, I would like to know if it is necessary to implement a Data Layer to push Custom Metrics and Custom Dimension data from Google Tag Manager to Google Analytics.

Some guides I have seen seem to suggest you do not need to implement a Data Layer: http://mixedanalytics.com/blog/custom-metric-ga-google-tag-manager/

However, there are others that suggest you need to: https://campaigntail.com/Blog/Ultimate-Guide-Custom-Dimensions-Metrics-Google-Analytics

When I say implement a Data Layer, what I mean is insert code like this into your website:

// Set value for custom dimension #3.
ga('set', 'dimension3', 'variant a');

// Set value for custom metric #1.
ga('set', 'metric1', 1);

// Send pageview. Passes the dimension and metric to GA.
ga('send', 'pageview');

I have tried implementing the first method but failed. So was wondering what is the right way to go about it.

Thank you.

1

1 Answers

0
votes

(Edited because of stupid). Your code example does not show a datalayer, it shows a part of Google Analytics tracking code that wouldn't event work with a standard GTM setup (because GTM uses unique tracker names).

A datalayer is an an array of JSON objects that you can use as a container for your data. However GTM is happy to accept data from almost anywhere, including values that are directly written into your tracking tags. So no, you do not need a datalayer (other than in the sense that GTM will automatically create the datalayer that it needs to function).

Remember the data takes some time (up to 24 hours) to show up, and custom dimensions/metrics are not part of the standard reports. You have to create custom reports, or select your custom dimensions as secondary dimension in a standard report.