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.

Yahel
37.4k23 gold badges108 silver badges156 bronze badges
asked Dec 21, 2010 at 13:55
3
  • Why is this relevant? Or is it just for curiosity? 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.

answered Dec 21, 2010 at 14:22
Sign up to request clarification or add additional context in comments.

4 Comments

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.
It executes them when you push(); the queue is only used until the library has loaded.
but how does they do it? I mean, is an Ajax request? Do they create a script tag with a reference to their server?
@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/…
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)

answered Dec 23, 2010 at 11:38

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.