GTM dataLayer.push Examples (Standard, Ecommerce, Advanced)

Comments:2

  1. I’m having a little trouble getting this to work and I’m not sure how I can go about debugging it. I think I’ve followed the directions in the article properly. It’s a little fuzzy to me how exactly GTM hears the event being fired. I put mine within a click event handler that simply pushed the values into the dataLayer object as you’ve outlined in the first step. Does GTM watch for changes to that object, or is there something else I need to do to make GTM pass the values?

    1. Hey Mike, that should work fine. GTM will pick up any data layer pushes automatically, so you don’t need to do anything else. However, you can’t do anything with these values until you push them into triggers and variables. So if you’re pushing an event called trackEvent into the data layer, in GTM you now need to go to Triggers > New > Custom Event and enter Event name = trackEvent. Similarly, if you’ve pushed a key named pageType into the data layer, in GTM you should go to Variables > New > Data Layer Variable and enter Data Layer Variable Name = pageType. Then you can use trackEvent as a trigger, and push pageType into any of your tags.

Leave a Reply

Your email address will not be published.