Text Link Ads

Friday, June 27, 2008

Tracking your site with Google Analytics

Ok, so you have a web site (or a blog) and you've created some great original content. How can you get information about who is visiting your site? Well there are a lot of options which range from using tools that are built into your site provider (including log analyzers like Webalizer) to systems costing several thousand dollars like ClickTracks pro. One of the nicest and most powerful tools, though, is completely free and provided by Google: Google Analytics.

After you create your account by signing in with your google account (or creating one if you don't have one) you will be able to add your site to your analytics dashboard by clicking "Add Website Profile"

From here you first enter your site's domain name and select the radio button for "Add profile for a new domain" which means a new Google Analytics domain, not necessarily that your domain itself is new. On the next screen is the first "gotcha".

By default Google Analytics has the legacy tracking code selected. You should click the tab for "New Tracking Code" (as we've done in the image) to use the most up to date tracking code. This is important because it allows you to track links that go offsite (like affiliate links!) and without using the new code you'll have no way to quantify how many people are clicking on your advertisement links and banners.

This tracking code needs to go in the HTML of every page on your site, right before the </body> tag. We recommend that you set up the html files on your site with a php extension (even if the content is not dynamic--yet) so that you can use php include files to encapsulate code like the tracking code above. So you could paste the Google Analytics code for your website into a file called ga.php and then in your site files you can put right before the </body> tag. Again this will only work if you are using a file with a php extension, so you'd set up your index page as index.php. Don't worry you don't need to know a lot of php programming to do this, in fact you can put 100% html in this file and it will work just fine, but it will allow you to add bits of php into your HTML like the include above which are VERY nice.
Also, if you decide to add other tracking to your site (e.g. Quantcast) you can simply add the extra tracking code inside the ga.php file and all of the pages that included that file are instantly updated.

Ok, so you've got your tracking code set up in all the files you want to track in your site and you've clicked finish on the Google Analytics screen.

Now you have to wait...  Google Analytics processes data once a day, usually in the late-night/early-morning hours.  The next day when you log in you can click view reports and get the actual reporting screen.

And you can start seeing who's coming in, what pages they are visiting the most and lots of other information.  We'll go into more of all that in future posts, but for now you've got some real data on your site and it didn't cost you a penny!