How google ga.js is working?

7.4k views Asked by At

I tried to analyse how google is transfering data. Especialy the document.referer.

for me its not ajax (firebug do not show any ajax activity).

PHP do not show the $_SERVER['HTTP_REFERER'] very reliable

Any idea?

Is there a uncompressed sourcecode of the ga.js in the world?

4

There are 4 answers

1
Adnan On
2
Sarwar Erfan On
for me its not ajax (firebug do not show any ajax activity).

Just pay attention... look at the JS tab or Firebug.

You are adding http://www.google-analytics.com/ga.js in your page.

So, even before the page is loaded, googgle-analytics server already got a request sent to it :) There is no need to use ajax.

And you can beautify ga.js using the tool Adnan has mentioned in his answer to see what the ga.js does after it is loaded

==== EDIT ==== enter image description here

0
Martin Konecny On

After the analytics file is downloaded, it runs and reads document.referer in Javascript, and then sends this information off to Google. You can see all the parameters it collects by looking at your browser's dev console - here's a picture from Google Chrome:

enter image description here

0
Stuart W On

Instead of including ga.js try using http://www.google-analytics.com/u/ga_debug.js

It is still minified and compressed, but it does have plenty of logging and debugging info

http://code.google.com/apis/analytics/docs/tracking/gaTrackingTroubleshooting.html#gaDebug