Google Analytics - Can I download the logs?

Can I download the raw logs of my Google Analytics data? I want to do some processing on the data.


Solution 1:

Well, you can't directly access GA's logs, but it's not difficult to regenerate a GA log (for your own GA account) with complete fidelity.

We know exactly what data are in these GA logs because Google has told us. Google has also explained how the data comprising the log is collected.

Here's the gist: All of the reports/data views in the GA web browser are created by parsing a transaction log which in turn is created one line at a time. The GA server collects every one of those lines in exactly the same way--by receipt of a long list of parameters appended to a client request for a single-pixel GIF. (This request is initiated by the ga.js which downloaded and executed by the client/browser.) That list of parameters is comprised of all GA data sources: the location bar ('http://wwww....'), the HTTP Request headers, data from the DOM, cookies set/updated on the client. The data from all of these sources are aggregated and packed into this parameter list and appended to the request for __utm.gif.

An example:

http://www.google-analytics.com/__utm.gif?utmwv=4&utmn=769876874&utmhn=example.com&utmcs=ISO-8859-1&utmsr=1280x1024&utmsc=32-bit&utmul=en-us&utmje=1&utmfl=9.0%20%20r115&utmcn=1&utmdt=GATC012%20setting%20variables&utmhid=2059107202&utmr=0&utmp=/auto/GATC012.html?utm_source=www.gatc012.org&utm_campaign=campaign+gatc012&utm_term=keywords+gatc012&utm_content=content+gatc012&utm_medium=medium+gatc012&utmac=UA-30138-1&utmcc=__utma%3D97315849.1774621898.1207701397.1207701397.1207701397.1%3B...

This is not difficult to parse--each parameter is a variable beginning with 'u', eg, 'utmn.' Each parameter in turn has a value. 'utmn' for instance is the GA Account ID; and 'utmcc' are the cookies. You can decode the various GIF Request paramaters by referring to the GIF Request Parameter lookup table provided by Google.

Sp to recreate GA's log for your GA account, you just need to capture each of these GIF Requests. It's not difficult to log all of this data to your Apache activity log:

First, add this line to the GA tracking code for each page on your Site:

page.Tracker.__setLocalRemoteServerMode();

This provokes a request for __utm.gif from your webserver as your page is loaded.

Then add this resource (__utm.gif) to your web server root so that you can serve it.

Solution 2:

I don't think you can get the raw logs, but you can certainly access the data via an API, outside of your web browser:

http://code.google.com/apis/analytics/docs/gdata/gdataDeveloperGuide.html