The documentation for implementing Enhanced Ecommerce says to use pageviews to capture data for things like product-detail views and events for things like product clicks.
But the advice I've seen from everyone else is to send events for everything. And furthermore, where I've followed the documentation for capturing data through pageviews instead of passing an event, the data does NOT get passed to GA. For triggers, I tried with a custom event named gtm.dom
and the built-in DOM Ready
events to no avail.
For product-detail views, for example, dataLayer
looks exactly as it should when the page loads. This is dataLayer[0]
:
{
"ecommerce": {
"detail": {
"products": [
{
"quantity": 1,
"price": "69.95",
"brand": "Acme",
"id": "SKU",
"name": "Quasitronic Fluxicator"
}
]
}
}
}
And in GTM I can verify that Enable Enhanced Ecommerce and Use Data Layer are checked.
use pageviews to capture data for things like product-detail views and events for things like product clicks
This is still probably the case but you can still set things up to track everything through events (though sometimes it might not be the best). With the former method, you would probably want to use a PV tag that fires on the All Pages
trigger (which is essentially the gtm.js
event) for things like impressions and prod detail views, and then use an event for click events like ATC or prod click (so things that don't need to be tracked by viewing them). Make sure that if you use the All Pages
trigger, your data is available in the dataLayer BEFORE your GTM container code loads. This is very important.
In the latter method, if you choose to use an event for everything (which is possible), you need to make sure that you push an event
along with the DL data, and then use that event
to fire your tag. So if you are using an event to replace a pageview for tracking EE data, then make sure you have an event associated with the data in the dataLayer to trigger off of.
I've followed the documentation for capturing data through pageviews instead of passing an event, the data does NOT get passed to GA ... I tried with a custom event named gtm.dom and the built-in DOM Ready events to no avail
What might be happening is that your data is not available yet by the time your pageview fires. If you are using the gtm.dom
event, then you need to make sure all your data is in the dataLayer by the time that event happens. You can use GTM debug mode to see when your data is available by clicking on the events in the left panel. If you click a particular event for which you want to track ecomm data and the data is not in the dataLayer already, then you'll get nothing.