Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • thanks for your answer. When you say use of the event key is vital you mean when creating variables in GTM? Commented Nov 22, 2017 at 16:00
  • When you push data to the dataLayer, it's a good practice to always push an event as well, eg. dataLayer.push({'event': 'test', 'category': 'chicken'}). That way you can be sure that when you want to fire your tag and use the correct category value, you can do so with the test event as your trigger. Commented Nov 22, 2017 at 16:03
  • Great, this is what I am doing, thanks. In regards to using nested data structure, would it be something like dataLayer.push({'event': 'animal', 'animal':[{'name': 'chicken'}, {'habitat':'farm'}]) and then the variables will be defined as animal.name and animal.farm? Commented Nov 22, 2017 at 16:20
  • It would be more like dataLayer.push({'event': 'animal', 'animal':[{'name': 'chicken', 'habitat':'farm'}]), and then to access them as data layer variables in GTM, you would go animal.0.name and animal.0.habitat. Commented Nov 22, 2017 at 16:26
  • thanks, I think this is the best approach. This way I could define only a single variable animal in GTM and then access the single elements from the tag. Commented Nov 22, 2017 at 16:32