3

Here's the GA output code:

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA_CODE']);
  _gaq.push(['_setDomainName', 'SUBDOMAIN']);
  _gaq.push(['_trackPageview']);
  _gaq.push(['_trackEvent', 'Priority', 'Created (day)', 'Label info', '']);



  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

the trackEvent line seems to be correct...but not tracking for some reason. Is it because I left the value field nil?

2 Answers 2

6

For _trackEvent, the value parameter should be an integer. Since it's an optional parameter, you can just leave it out:

_gaq.push(['_trackEvent', 'Priority', 'Created (day)', 'Label info']);

Having a non-integer value will prevent the event from being tracked.

Sign up to request clarification or add additional context in comments.

7 Comments

I changed that and now it is saying that my visitors are sending events (401 of your visits sent events) but it still says 0 total events. I only made this change a few hours ago, could there not be enough time to load events yet?
@MatthewBerman probably it will take a day or 2 to start showing those events
@eduardocereto Oh really? Ok that's odd but I will report back in a couple days. It's weird because it IS saying users are delivering events but the actual events are not showing up. Has that been your experience? Also, my test event (forgot how I actually triggered this event) showed up the same day it came through.
@Matthew Berman--I'm also dealing with this issue; it shows that 52 of my visits sent events, but there is no event data passing through. It's been over 24 hours, which should be plenty of time to have some data in there.
@TonyTheJet If that's the case you're probably using the wrong tracking call. The example in the Google docs is for the asynchronous tracking code (so of the form _gaq.push(['_trackEvent', ...])). If you're using the traditional code you need to make a call of the form pageTracker._trackEvent(...). I made this mistake myself and saw exactly the same result you're describing. As soon as I changed it, it worked as expected.
|
1

I beleive _trackEvent won't work properly when called from GA tracking code snippet, at least it was not made for such usage. If you want to execute an event after page loads, try calling it for example from onLoad event of your body tag.

Secondly, passing an optional value parametr as '' would make it undefiened, which looks like it could produce an error, so, since it's optional, don't pass it at all.

And there's a delay in GA reportings, data processing takes about 24 hours (you can switch between new and old versions, sometimes one shows data faster than another).

6 Comments

Also '' and undefined are completely different things. This is a perfect example. If you pass value as an empty string ('') it won't work, but if you omit it or pass it as undefined the Event works.
I beleive emptystring and undefiened may be or may be not differrent, that would depend on conditional statement. in JS '' == undefined is true and '' === undefined is false. In any case, passing both empty string and undefiend var in that optional parametr makes completely no sence.
As for _trackEvent in tracking code, my point was that it won't work for a number of reasons, for example, this method was not designed to be called from the code, would withdraw page bounce rate at once etc. But this is my thoughts, i haven't checked it.
Good point. You still can use the opt_noninteractive flag to avoind breaking the bounce rate. _gaq.push(['_trackEvent', 'Cate', 'Act', 'Lab', 0, true]);
Yeah, but executing such event in GATC would just duplicate a standard GA pageview data in event tracking report. What's the point of using it then?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.