Setting up Google Analytics is pretty easy work thanks to google
If you dont have a Analytics account yet you can get one here: Google Analytics
To start tracking just add the code below to the page(mostly before the end of <body> tag) that you wish to track using Google Analytics
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "<a href="https://ssl."">https://ssl."</a> : "<a href="http://www.");">http://www.");</a>
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("XX-XXXXXX-XX");
pageTracker._trackPageview();
} catch(err) {}</script>
Note: Make sure that you replace the ‘X” with your tracking id.
A bit tricky part is tracking downloads for PDF and Flash files.
But since google rocks they have made this simple as well.
To track a file download add the following code to the anchor tag’s onclick event
pageTracker._trackPageview('/downloads/myfile.pdf');
The complete anchor tag would look like something below:
<a href="/myfile.pdf" onclick="pageTracker._trackPageview('/downloads/myfile.pdf')">My Pdf</a>
When the user clicks on the above link , you will see the ‘/downloads/myfile.pdf’ url in your analytics report.
This technique can be used to track other file types as well (Flash, WMV, AVI, MOV, etc..)