20

I have Google Analytics setup on my site, and it is definitely recording page views. But I have added some code to call pageTracker._trackEvent(category, action, label, value), and it is not recording those hits or showing them in the reports.

BTW, yes, I have waited for over 24hrs to see if the hits are in the reports.

I have used the standard Google script include as well as the technique mentioned here. Neither one seems to help the _trackEvent() problem.

Can anyone give me some advice on how to track down what's going wrong? I'd be happy to post code examples if you let me know what parts are important.

Thanks.

Community
  • 1
  • 1
slolife
  • 19,520
  • 20
  • 78
  • 121
  • Can you show some real world code snippet how you applied it? According to your description, everything is alright. – viam0Zah Jul 21 '09 at 16:04

4 Answers4

40

The problem was the values that I was putting in the final argument, the "value" parameter.

pageTracker._trackEvent(category, action, label, value)

I was passing non-integer strings to the "value" parameter:

pageTracker._trackEvent("UserAction", "ShowHelp", "Page", "http://mysite/UrlGoesHere");

but the docs say it needs to be an integer value.

pageTracker._trackEvent("UserAction", "ShowHelp", "http://mysite/UrlGoesHere",  1);

I posed the question on Google Help Forums here.

And here is a link to the Event Tracking docs

Thanks for the help Török

slolife
  • 19,520
  • 20
  • 78
  • 121
  • 1
    you saved my day. i was in stuck with it by sending a float as the value and it was not working :(. thanks a lot. – HungryCoder May 03 '12 at 08:52
  • 2
    Note: the google analytics debugger chrome plugin (developed by Google) is clever enough to report this problem : https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna – Simon_Weaver Mar 05 '13 at 01:10
  • Also general debugging guidelines can be useful https://developers.google.com/analytics/resources/articles/gaTrackingTroubleshooting – Simon_Weaver Mar 05 '13 at 01:10
  • This only works if you have the async Google Analytics tracking code installed on the same page... https://developers.google.com/analytics/devguides/collection/gajs/asyncTracking – ATSiem May 14 '13 at 03:40
  • 1
    Good to note that **integer** seems to be wanted, even though [some documentation ](https://developers.google.com/analytics/devguides/collection/analyticsjs/events) says **number**. – Touko Aug 23 '13 at 06:24
7

Similarly, label can not be an integer or the _trackEvent function fails silently.

pageTracker._trackEvent('VLP', 'click-out', 12345);

Fixed as

pageTracker._trackEvent('VLP', 'click-out', '12345');
KevBurnsJr
  • 4,869
  • 2
  • 25
  • 16
4

Updated Answer

This question is still getting a lot of pageviews. I feel like the current visitors are facing a new problem that the other answers don't address.

New Analytics Means New APIs

If you are using the "Universal Analytics" snippet which is Google's new system they are trying to transition everyone over to. Some of the APIs have changed including event tracking.

Make sure you are using this:

ga('send', 'event', category, action, label, value);

Instead of this:

_gaq.push(['_trackEvent', category, action, label, value]);

For event tracking.

Here is a thorough blog post on the subject http://blog.tylerbuchea.com/tracking-events-in-googles-new-universal-analytics/

And here is the new documentation from Google https://developers.google.com/analytics/devguides/collection/analyticsjs/events

Tyler Buchea
  • 1,642
  • 3
  • 17
  • 25
1

it is not recording those hits or showing them in the reports.

Events have no effect on page views and do not appear on regular reports. Events have a seperate interface at Content / Events. If you'd like to track the things you specified as events like regular hits, better use the trackPageview method instead.

viam0Zah
  • 25,949
  • 8
  • 77
  • 100
  • You are correct, events are not regular page hits. Unfortunately (for me), I did know that, but the events are still not showing up in Content/Events. – slolife Jul 20 '09 at 15:52
  • @slolife: have you tried to manually change the URL? For instance, click on ‘Content/Site Search’ and replace ‘site_search’ with ‘events’? – viam0Zah Jul 21 '09 at 16:03