I have a single page ecommerce application and need to setup the google ecommerce funnel. My application sets the funnel steps in the Tag Manager dataLayer
Nothing in the documentation indicates when the datalayer is actually sent to Google Tag Manager.
window.dataLayer starts the page with:
event: 'checkout',
ecommerce: {
checkout: { actionField: {step: 1, option: 'Checkout Options'}}
}
on the first button click
$(document).one('click','#button-payment-address', function () {
window.dataLayer.push({
'event': 'checkout',
'ecommerce': {
'checkout': {
'actionField': {
'step': 2,
'option': 'Billing Details'
}
}
}
});
});
The dataLayer becomes:
event: 'checkout',
ecommerce: {
checkout: { actionField: {step: 2, option: 'Billing Details'}}
}
On the second button
$(document).one('click', "#button-shipping-address", function(){
window.dataLayer.push({
'event': 'checkout',
'ecommerce': {
'checkout': {
'actionField': {
'step': 3,
'option': 'Delivery Details'
}
}
}
});
console.log(window.dataLayer);
});
The dataLayer becomes:
event: 'checkout',
ecommerce: {
checkout: { actionField: {step: 3, option: 'Delivery Details'}}
}
And so on...
When does the dataLayer get sent or is there a way to force a send, reinitialize the dataLayer and then push the next step?
UPDATE: I was looking under Firefox DevTools/network/XHR for the traffic and could not find any. Looking under DevTools/network/images shows the data being posted on each click.