Google Analytics Event Tracking?

Hey guys,

Our client uses Event Tracking in Google Analytics to capture certain link/button clicks on their website.

E.g. clicking “Submit” on a Contact Form or clicking “Subscribe” on a Newsletter subscription form.

We have tested the Event Tracking on all of their forms and it is failing to be capture the data into their Analytics account.

Default setup:
onclick=”ga(‘send’, ‘event’, ‘Category’, ‘Action’, ‘Label’, ‘Value’);”

I have tried multiple versions like:

<input type="submit" onclick="ga('send', 'event', 'Enquiry', 'Submit', 'Contact Form Submission', '');">
<input type="submit" onclick="ga('send', 'event', 'Enquiry', 'Submit', 'Contact Form Submission');">
<input type="submit" onclick="ga('send', 'event', 'Enquiry', 'Submit', 'Contact Form Submission', '');">
<input type="submit" onclick="ga('send', 'event', [Enquiry], [Submit], [Contact Form Submission]);">

It seems no matter what we do it is failing to capture the event, we even tested a basic link:
<a href="/grants" onclick="ga('send', 'event', 'Grants', 'Click', 'Clicking Grants link');">Click</a>

We have triple checked to make sure the same Analytics account is being used and that it matches up with the same UA-Tracking code we’ve added in Settings -> Analytics.

They can see their Analytics stats as well on the Dashboard when you log into the Treepl admin area. However when we setup an Event and trigger it, and then log into the Google Analytics account and head over to Behaviour -> Events -> Overview (with today’s date selected) - nothing is being shown, no data is coming over.

We even tried scrapping Analytics from Treepl’s Settings -> Analytics and just pasting the snippet from Google Analytics into the tag and tested the Event again and same again, no data is hitting the Analytics account.

Is this a Treepl issue? Has anyone successfully tracked an Event on Treepl?

Does the Google Tag Assistant browser plugin help identify the issue?
https://support.google.com/tagassistant/answer/2947093?hl=en&ref_topic=6000196

The issue here is that Google Analytics is installed using the latest global site tag so you need to swap your event tracking over to this - https://developers.google.com/analytics/devguides/collection/gtagjs/events

1 Like

Thanks!! That worked! Had no idea Analytics had implemented a new .js

Yes we have changed all our event tracking over with each migration so it is something to consider when quoting.

Oh I was checking this out today. Ive just pasted the code here to save you digging…

Old analytic.js version:

ga('create', 'GA_MEASUREMENT_ID', 'auto');
// Uses the default tracker to send the event to the
// Google Analytics property with tracking ID GA_MEASUREMENT_ID.

ga('send', 'event', 'Videos', 'play', 'Fall Campaign');

New gtag.js version

// Sends the event to the Google Analytics property with
// tracking ID GA_MEASUREMENT_ID set by the config command in
// the global tracking snippet.

gtag('event', 'play', {
  'event_category': 'Videos',
  'event_label': 'Fall Campaign'
});