_trackEvent() from Google Analytics not working?

前端 未结 4 1311
不思量自难忘°
不思量自难忘° 2020-12-31 01:45

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, labe

相关标签:
4条回答
  • 2020-12-31 01:57

    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

    0 讨论(0)
  • 2020-12-31 01:57

    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.

    0 讨论(0)
  • 2020-12-31 02:09

    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

    0 讨论(0)
  • 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');
    
    0 讨论(0)
提交回复
热议问题