Dreadlord Dreadlord - 1 year ago 259
Javascript Question

GTM data layer eventCallback function

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.

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() {
<!-- 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>
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
<!-- 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?

Answer Source

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";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download