Google Analytics is a wonderful tool for tracking how people interact with your website.
Basic Theory
You sign up for Google Analytics and they give you a code snippet which you install on every page you want to track. The code snippet remains the same for an entire “property.”
Tips
Create a property for each unique website.
Put the code in one centralized location and reference it on pages. Google periodically changes their code, so you don't want to have to change it in multiple places when they upgrade.
Installing
Create a file “analytics.js” and place the code snippet inside.
Upload that to your webserver.
Make sure to remove the <script> and </script> tags.
It should look like this:
(function(i,s,o,g,r,a,m){i[['GoogleAnalyticsObject']]=r;i[[r]]=i[[r]]||function(){
(i[[r]].q=i[[r]].q||[[]]).push(arguments)},i[[r]].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[[0]];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','<nowiki>//</nowiki>www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXXX-1', 'auto');
ga('send', 'pageview');
Static Webpage
There are a lot of tutorials that tell you to insert the code into a skin, but what if a user changes skins? What if you get tired of your skin? That method is stupid.
Common.js is a MediaWiki special page that runs javascript on every page load. Doesn't that sound perfect? Bloggers are retarded.
Open Common.js by going to: /YourWiki/index.php?title=MediaWiki:Common.js
Edit the page to add:
document.write("<script type='text/javascript' src='/analytics.js'></script>");
Wordpress