0

Hi there: When you need to register some javascript activity from your web site into google analytics they say you may use (for example):

_gaq.push(['_trackEvent', 'Param1', 'Params2']);

or

_gaq.push(['_trackPageView', 'URL']);

Does anybody knows this function call works? Does it make an Ajax request to Google in order to send the data? Does it store the info and pushes it to the server on unload event?

Thanks.

3
  • Why is this relevant? Or is it just for curiosity?
    – jwueller
    Commented Dec 21, 2010 at 13:57
  • It's curiosity and I was wondering about the risk of trackig mouse drag events if it's sending a request every time the event is raised. Commented Dec 21, 2010 at 15:25
  • Or a user click 10 times (for example) in the same link in a row... Commented Dec 21, 2010 at 15:37

2 Answers 2

1

_gaq acts as a queue so you can push commands before Analytics has fully loaded; once it has it will start executing what you've queued. See the docs.

4
  • Yes I know; I read the docs and I understand how does it work while analytics library in loading. I need to know how does it work ONCE the library is loaded every time I issue a command with push() method. Commented Dec 21, 2010 at 15:23
  • It executes them when you push(); the queue is only used until the library has loaded.
    – Wooble
    Commented Dec 21, 2010 at 15:53
  • but how does they do it? I mean, is an Ajax request? Do they create a script tag with a reference to their server? Commented Dec 21, 2010 at 17:38
  • @PaquitoSoft No AJAX, no JSONP. They just make additional requests to an image with your data appended, and their servers parse and process those requests. See: stackoverflow.com/questions/414451/…
    – Yahel
    Commented Dec 22, 2010 at 17:01
0

Thanks a lot to yc who finally gave the answer I was looking for. I just put it here so I can mark this question as solved.

As he pointed, they make a clever approach to this problem requesting an image file in their servers passing some parameters; this way they can avoid cross-domain issue. The link he wrote (this one) also has a reference to page from analytics google group with more info (Analytics Google group)

Not the answer you're looking for? Browse other questions tagged or ask your own question.