I'm using Google Tag Manager and implementing Enhanced Ecommerce tracking via dataLayer
. Everything is working fine. However, I'm now adding a CTA (call to action) that I want to track impressions for (there's multiple versions). This CTA is rendered as a partial, so at the time dataLayer
is being constructed, it doesn't exist yet and I have no idea what will end up being there.
With straight Google Analytics, it looks like you can manually track an impression via:
ga('ec:addImpression', {
// impression data
});
But, this doesn't work with GTM, as ga
is not defined in that scenario. According to the GTM Enhanced Ecommerce documentation, the only other "option", is to manually track the impression through the GTM control panel based on page view. Again, that's not feasible as the impression data is not always the same.
After a little research, I found a third "option" in delaying pushing dataLayer
. For example, instead of letting if fire on GTM load, you can tie it to a particular event and then send that event at a later point. I suppose that would let me, then, alter the dataLayer
in this partial, as long as I made sure that the event was not sent until well after it's been rendered. However, that not only seems clunky and prone to error, but it would also require me to substantially alter the rest of my Enhanced Ecommerce tracking code.
Is there no way to just send the impression as you can with straight GA, with GTM?