Google Analytics Event Tracking - Minimal Interval

2019-02-24 13:27发布

I want to track multiple events using GA _trackEvent method across multiple domains.

Because of the nature of the report I want to generate, I must do something like this:

for (var i=0; var < books.length; i++)
{
   //showing values for current books[i]
   _gaq.push(['_trackEvent', 'Books Displayed', 'Fantasy', 'Lord of The Rings']);
}

So, when my books list is populated I want to send appropriate GA event. It is important that I send each item separately so I can drill-down on Event Dashboard to preview all items in 'Fantasy' category and so on.

Note, books list is never longer than about 10 items.

The problem I'm experiencing at the moment is that for no good reason Google code is ignoring some of my requests. The way how Google event tracking works, is that with every call to _trackEvent, Google is dropping gif on the page:

http://www.google-analytics.com/__utm.gif

that has loads of parameters, and one of them - utme contains my data:

__utm.gif?utmt=event&utme=5(Books%20Displayed*Fantasy*Lord%20of%20The%20Rings)

Using Fiddler (or Firebug Net tab) I can check if this request is really coming out from the browser.

Unfortunately, it seems like every time about half of my requests are completely ignored by google and _trackEvent is not translated to __utm.gif call.

I have a feeling it has something to do with the frequency of the _trackEvent call. Because I am using them inside a for loop, all events are spawned with minimal interval between. It seems like Google doesn't like it, and ignores my calls.

I did test it, adding 2 seconds interval between each call and it worked. But this solution is unacceptable - I can't make user wait for 20 seconds to send all events.

Unfortunately this flaw makes GA Event Tracking completely useless - I can't just "hope" GA code will correctly record my event because the report won't be precise. The worst thing about it is that there is no proper documentation on Google saying what is the maximum allowed number of requests per second (they only state that max request per session is 500 what is a lot more than what I generate anyway).

My question is - did you experience similar problems with Google Event tracking before and how did you manage to fix it? Or does it mean I must completely abandon GA Tracking because it will never be precise enough?

2条回答
姐就是有狂的资本
2楼-- · 2019-02-24 13:44

This is probably due to the 1 event per second limit

"Events Per Session Limit

In addition to general collection limits and quotas, the following limit applies to event tracking in ga.js:

The first 10 event hits sent to Google Analytics are tracked immediately, thereafter tracking is rate limited to one event hit per second. As the number of events in a session approaches the collection limit, additional events might not be tracked. For this reason, you should:

avoid scripting a video to send an event for every second played and other highly repetitive event triggers avoid excessive mouse movement tracking avoid time-lapse mechanisms that generate high event counts

(from https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide)

That is why your 2 seconds delay works. You can theoretically cut that in half, though a factor of safety would probably reduce that cut.

查看更多
Emotional °昔
3楼-- · 2019-02-24 14:02

First off, I want to point out that the 500 limit per session is for all requests to Google, not just for events. So that includes any other custom tracking you are doing, and that also includes normal page view hits.

This to me sounds more like a general js issue than a GA issue. Something along the lines of you pushing code for GA to process faster than it can process so some are falling through the cracks. I don't think there really is anything you can do about that except for delay each push as you have done...though I think you could probably lower that interval from 2s to maybe as low as 500ms...but still, that would at best drop you down to a 5 second wait, which IMO is a lot better than 20s but still too long.

One solution that might work would be for you to skip using _gaq.push() and output an image tag with the URL and params directly for each one. This is sort of the same principle as the "traditional" GA code that came before the async version, and is what most other analytics tools still do today.

If you want my honest opinion though...in my experience with web analytics, I think the most likely thing here is that you need to re-evaluate what you are tracking in the first place.

Judging by the context of your values, (and this is just a guess) it looks to me like you have for instance a page where a user can see a list of books, like a search results page or maybe a general "featured books" page or something similar, and you are wanting to track all the books a user sees on that page.

Based on my experience with web analytics, you are being way too granular about the data you collect. My advice to you is to sit down and ask yourself "How actionable is this data?" That is, after all, the point of web analytics - to help make actionable decisions.

All day long I see clients fall into the trap of wanting to know absolutely every minute detail about stuff because they think it will help them answer something or make some kind of decision, and 99% of the time, it doesn't. It is one thing to track as an event individual books a user views, like an individual product details page, where you'd be tracking a single event.

Or for search results page...track it as a "search" event, popping stuff like what the term searched was, how many results given, etc.. but not details about what was actually returned.

I guess if I knew more details about your site and what this tracking is for, I could maybe give you more solid advice :/

查看更多
登录 后发表回答