In this post, I will walk you through adding Google Analytics, a highly sophisticated website traffic analysis tool, to your blogs running on the SubText Blogging Framework.
Last Updated on: 11.Dec.2006
Applies to: SubText 1.9.2.30
Pre-requisites: An existing Gmail account.
Visit the Google Analytics website at http://www.google.com/analytics/ and sign in with your Gmail account.
After you are logged in, click the Sign Up button.
In the General Information screen, enter the website details as requested and Click Next.
In the Contact Information screen, enter your contact information and Click Next.
Read the user agreement conditions in the ‘Accept User Agreement‘ Screen carefully, and if you agree to it, check the “Yes, I agree to the above terms and conditions” box and click Create New Account.
The Analytics – Tracking Instruction screen will be displayed.
Copy the entire script in the box, and paste it temporarily in a text document like a new notepad or wordpad document. Click Next.
You will now be taken to the main Analytics screen. At the top, you will see a message saying that ‘Tracking for your website has not yet been validated‘. Don’t panic. This is expected because you haven’t added the code in your website pages that will allow Goggle Analytics to track your website.
The easiest way to ensure that the Google Analytics Tracking Code to your subtext blog is to add it in the blog skins’ master page control (PageTemplate.ascx). Since this page control is visible in all the pages in your website – except the admin pages, where you don’t want this code anyway – this is the recommended method to include the tracking code. So let’s go ahead and add the tracking code to your blog skins’ master page control
In a text editor or in Visual Studio (if you have it), open the PageTemplate.ascx page located in the site_root\Skins\skin_name\ folder and paste the tracking code immediately below the last < Register> line at the top of the page so that the script appears as shown below.
Save and close the PageTemplate.ascx file. If your site is hosted somewhere, copy and overwrite this PageTemplate.ascx onto the corresponding folder in the host.
If you are hosting multiple SubText blogs on the same domain, then repeat this PageTemplate.ascx modification for each skin for each of those blogs.
Next, open a browser window and visit the website.
Now right click on the page and click View Source and ensure that the Google Analytics tracking code is visible.
Visit the Google Analytics website and sign in with your Gmail account.
You will now be taken to the main Analytics screen. At the top, you will see a message saying that ‘Tracking for your website has not been validated‘. Now that we have added the tracking code, click the Check Status Button.
It is quite likely that you will be informed that the Tracking is Not Installed.
Here is the important part. Be patient. Often, it takes anywhere from a few minutes to a few hours for Google Analytics to detect the tracking code on your site and start gathering traffic statistics. So if you do get the ‘Tracking is Not Installed‘ message, just wait patiently. Take a walk, drink coffee, or if it is late at night, go to bed and then logon to your google analytics account again.
If the Tracking is successfully detected, then you will see it your website listed in the Website Profiles Table. The status column in the website profiles table will also show a status of ‘Receiving Data‘
Click the “View Reports” and you are ready to see the traffic on your website !