I have added the below code to the head tag of my website, but when I navigate through the pages and make a transaction, the data doesn't flow through to the Real Time -> Events tab on the Google Analytics dashboard. However, I can see data when I go to the Real Time -> Content tab (it shows all the pages viewed in the last 30 minutes).
<script>
(function(w, d, s, l, i) { w[l] = w[l] || []; w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' }); var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f); })(window, document, 'script', 'dataLayer', 'GTM-PCQXYZ2');
</script><script type="text/javascript">
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
"event": "transaction_completed_event",
"transactionId": "12345",
"transactionAffiliation": "18CA",
"transactionTotal": 0.01,
"transactionTax": 0,
"transactionShipping": 0,
"transactionProducts": [{
"sku": "SKU-TEST",
"name": "Product Name Test",
"category": "Category Test",
"price": 0.01,
"quantity": 1
}]
});
</script>
Am I missing anything here?
The code you are using is not relative to the enhanced ecommerce but standard ecommerce: https://support.google.com/tagmanager/answer/6107169?hl=en
Have you configured a trigger on Tag Manager that is activated with a custom event named 'transaction_completed_event' that fires an Analytics event tag?