Monday, May 20, 2024
27
rated 0 times [  32] [ 5]  / answers: 1 / hits: 16919  / 10 Years ago, fri, november 7, 2014, 12:00:00

So i have Ecommerce code setup in GTM data layer, but after that is sent to Analytics i want the page to be redirected so i know i should be using eventCallback but it is not working for some reason.



<body>
<script>
dataLayer = [{
'transactionId': '56833',
'transactionAffiliation': 'TestName',
'transactionTotal': 1540.00,
'transactionTax': 385,
'transactionShipping': 0,
'transactionProducts': [{
'sku': 'FFSS44HH',
'name': 'test',
'category': 'TestCategory',
'price': 1540.00,
'quantity': 2
}],
'eventCallback': function() {
document.location.href='https://www.paypal.com/something';
}
}];
</script>
<!-- Google Tag Manager -->
<noscript><iframe src=//www.googletagmanager.com/ns.html?id=GTM-XXXXX
height=0 width=0 style=display:none;visibility:hidden></iframe></noscript>
<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=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXX');</script>
<!-- End Google Tag Manager -->


I have set up Ecommerce firing rule in GTM for this URL. I tried hitCallback and eventCallback but the redirect does not happen... What am i doing wrong here?


More From » google-analytics

 Answers
9

i think i found a solution, i just added this ('event' : 'datalayerReady') at the end of the data layer:



'event' : 'datalayerReady',
'eventCallback': function() {
document.location = https://www.paypal.com/something;
}

[#68871] Thursday, November 6, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sienad

Total Points: 208
Total Questions: 100
Total Answers: 77

Location: Taiwan
Member since Mon, Sep 6, 2021
3 Years ago
;