6

I am trying to add custom event tracking to a link on a site I built. For some reason it does not seem to be working. The code I have is:

onClick="_gaq.push(['_trackEvent', 'SOU Links', 'Click', 'Top edu banner']);"

The site URL is http://sou.wpengine.com/. The link with the event tracking is the "Sign Up Now" link at the top of the page. Any ideas?

Andrew
  • 1,121
  • 4
  • 15
  • 24
  • Please check that the for _trackEvent, the value parameter should be an integer. – Rahul Tripathi Sep 09 '13 at 19:28
  • What do you mean? In Google's documentation (here: https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide) they do not use an integer. They have it like so: Play – Andrew Sep 09 '13 at 19:32

4 Answers4

13

I had an issue with events not tracking (using Universal Analytics).

I installed the official Google Analytics Debugger from

https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna

And it showed me a warning message that event value was expecting an integer, but receiving an empty string. Once I cleared that up, the events showed up in the realtime tracker right away.

Homer6
  • 15,034
  • 11
  • 61
  • 81
7

It appears you're using the advanced configuration setup described by google here. To track events, you'll want to use the event tracking methods described by google here.

Hope this helps.

Adding another helpful link: https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide

This will work for older tracking version: Tracking Basics (Asynchronous Syntax)

Mvg Developer
  • 183
  • 1
  • 7
bbone
  • 626
  • 5
  • 6
  • Nice, thank you. I didn't even realize the event tracking code had changed. Thank you! Should I include the jQuery snippet in the head of the document after the GA snippet or in the separate JS file? /cc @Blexy – Andrew Sep 09 '13 at 21:14
  • No problem, glad to help. I'm assuming you're talking about [this](https://developers.google.com/analytics/devguides/collection/analyticsjs/events#usingjquery)? If so, it's really your call . Just make sure you update the jquery selector to the appropriate id or class name and update the ga functional call with the appropriate values for your custom event. If this helped I'd appreciate it if you mark the response as answered. :-) – bbone Sep 09 '13 at 21:34
2

As bbone said, you are using the event tracking syntax for ga.js (Classic Analytics) and you have analytics.js (Universal Analytics) on your site.

If you want to track the "Sign Up Now" link, use this:

ga('send', 'event', 'SOU Links', 'Click', 'Top edu banner');
Blexy
  • 9,573
  • 6
  • 42
  • 55
  • Looking at the [docs](https://developers.google.com/analytics/devguides/collection/analyticsjs/events#overview), it seems like the final 'value' still needs to be a number. I've just been debugging my own custom events not working and wonder if this might be why. – Pete Feb 18 '14 at 14:23
  • the last parameter in @Blexy 's code is label not value, so doesn't have to be a number – 99 Problems - Syntax ain't one Dec 05 '14 at 11:21
1

you should send also _gaq.push(['_setAccount', 'UA-XXXXXX-1']); before the tracking event and install for chrome this extension to debug https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna

it worked for us

chispitaos
  • 767
  • 9
  • 14