Friday, June 19, 2009

Google Analytics - storage period

One of the disadvantages of Google analytics over other web analytics tool is that the storage period of your analytics data is just for 25 months. This is very sufficient for most Google analytics users. However, if we wish to retain data for longer period we just need to modify a single line of the Google Analytics Tracking Code (GATC). The additional code that you need to add is highlighted in bold below.

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-xxxxx-1");
pageTracker._setLocalRemoteServerMode();
pageTracker._trackPageview();
} catch(err) {}
</script>

4 comments:

Muthalagu said...

Hi Beno,

Nice information, but the data will store in our local server log files while adding the following line to the code
pageTracker._setLocalRemoteServerMode();

If i'm wrong please correct me.

Beno John said...

Great to hear from you Muthu. Nice question and you are partially right.

Well how it works is, when you add this single line of code it sends your data to Google Analytics collection servers and at the same time adds this data into your local web server log files. So the information is collected in 2 places. Hope this answers your question.

Avinash said...

Hm..Good one. I did not realize that. Thanks for sharing.

Beno John said...

@Avinash - welcome.