0
votes

I'd like to have any help regarding an events-firing issue with Universal Analytics deployed via Google Tag Manager.
In particular, I'm attempting to send two kinds of events on the same page: a checkout-purchase event (Enhanced-ecommerce) and an onclick generic custom one.
Below my page's related code, in the order of onload execution:

<script>
 <!--Initialize dataLayer-->
  dataLayer = [{'userId' : ...}];
 <!--End dataLayer-->

 <!--Tag Manager-->
  (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':.....})(window,document,'script','dataLayer','GTM-...');
 <!--End Tag Manager-->

 dataLayer.push({   
  'event': 'checkout',
  'ecommerce': {
    'purchase': {
        'actionField': {
            'id': ...
            'revenue': '1.00', 
            'tax': ... 
        },
        'products': [{
            'name': 'Product1',
            'price': '1.00',
            'category': 'Category 1',
            'variant': 'Variant1',
            'quantity': 1
        }]
    }
  },
  'eventCallback': function() {
        console.log("Purchase pushed!");        
  }
 });
</script>

<button onclick="dataLayer.push({'event': 'eventTest'});">CLICK ME</button>

As you see, the purchase event is correctly pushed at the page-load.
I state "correctly" because inspecting the dataLayer object in browser console, is revealing the added purchase child object.
In addiction, at the end you find a simple button which pushes another generic "eventTest" on its onclick handler. Even this event object is added to the dataLayer "queue".
For you to consider, these below are the page-load '200 status' requests concerning Google:
- gtm.js?id=GTM-... [www.googletagmanager.com]
- analytics.js [www.google-analytics.com]
- collect?v=1&_v=j35&a=211135512&t=pageview... [www.google-analytics.com]

In short, everything seems to be ok.
Obviously, when those pushes are done, no addictional requests are fired, but this is expected.
My questions is: when, and based upon what, the dataLayer "queue" data is sent?

In fact, no events data are reported in Analytics panel after several days from my tests.
The Analytics tag is based upon "All pages" firing rule, in Google Tag Manager, and "e-commerce elements", with advanced ecommerce features and dataLayer options, are all active.

Is there any other Tag Manager's options, or rules, I should set in order to make those events be collected?? Should those events be previously "registered" in Tag Manager's console?

Apologise for being long and thanks so much.



UPDATE:

I managed to make those events data collected, but I'm facing issues with events "labels" sent.
I mean that events are regularly recorded even in the Universal Analytics real-time panel, but as "undefined".

Inspecting Analytics' requests is showing "undefined" values for "ec" and "ea" parameters, both for ecommerce object "addToCart / removeFromCart" dataLayer.push, and for the generic onclick "eventTest" one.

What might be wrong with these?
Thanks so much.

2

2 Answers

2
votes

How does GTM observe the dataLayer is answered here.

The ecommcerce data is automatically evaluated at page load by the Google Analytics tag template, so your transactions are recorded.

For the custom event in your button you need to create a trigger, type "event", condition "event equals eventTest" and then create a Google Analytics tag configured for event tracking.

Google really messed up when it used the same terminology for completely different things in two products that are meant to be used together.

A GTM event does not track anything in Google Analytics, it's a "reserved" variable name in GTM that must be present and filled in to fire tags. On page load, DOM ready, clicks and submits it's filled automatically by GTM.

However GTM events do not track anything to Google Analytics. For that you need to create a separate Google event tracking tag that in turn is triggered by the GTM event (which, to make the confusion complete, might be triggered by a javascript event).

2
votes

In this case you should send one hit to Google Analytics to send enhanced e-commerce data and other hit to send Google Analytics event data.

It means that you should fire 3 Google Analytics tags on your page: one for pageview tracking (pageview type) with "All pages" trigger, one for enhanced e-commerce tracking (event type) with "event equals checkout" trigger and one for event tracking (event type) with "event equals eventTest" trigger.