How to add Google Analytics to your Community Server Blogs / Forums

Shiva

Overview

In this post, I will walk you through adding Google Analytics, a highly sophisticated website traffic analysis tool, to your vibrant, search engine optimized community that you have already built using Community Server.

Post History

Last Updated on: 12.Oct.2006

Applies to: Community Server 2.1

Pre-requisites: An existing Gmail account.

Sign up for Google Analytics

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.

google-analytics-signup-account-information

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.

google-analytics-tracking-code-and-instructions

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.

google-analytics-check-tracking-status

Add the Google Analytics Tracking Code to your Community Server Website Pages.

The easiest way to ensure that the Google Analytics Tracking Code to your website is to add it in the sitewide page footer. Since the footer is visible in all the pages in your website including the blogs, forums, galleries and downloads pages, this is the recommended method to include the tracking code.

The architects of Community Server have also separated the control panel footer from the regular site footer. This is a very good design move because if there wasn’t a separate footer for the control panel and you added the tracking code in one common footer page, then even your activity within the control panel will be tracked by Google Analytics, giving you a false sense of traffic.

So let’s go ahead and add the tracking code to your site footer.

In a text editor or in Visual Studio (if you have it), open the Master.ascx page located in the site_root\Themes\Default\Masters folder. Scroll down and located the  </BODY> html tag and paste the tracking code immediately above the </BODY> so that the script appears as shown below.

google-analytics-tracking-code-in-website-page

Save and close the Master.ascx file. If you site is hosted somewhere, copy and overwrite this Master.ascx onto the corresponding folder in the host.

Open a browser window and visit the website.

Now right click on the page and click View Source.

Either search for </BODY> or scroll down till you find </BODY> at the end.

Ensure that the Google Analytics tracking code is visible.

Confirm the Tracking Code on your Google Analytics Account

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.

google-analytics-check-tracking-status

It is quite likely that you will be informed that the Tracking is Not Installed.

google-analytics-tracking-status

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

google-analytics-website-profiles-table

Click the “View Reports” and you are ready to see the traffic on your website !

google-analytics-website-traffic-statistics

2 Comments For This Post

  1. Dave Says:

    Thanks for the info. Why do you suggest editing master.ascx instead of just using the raw header feature in the control panel?

  2. Shiva Says:

    I suggested editing the Master.ascx, so that the script will be just before the ending </BODY> tag like Google recommends.

    The raw header feature should also do the job I guess, and will probably be easier for non-techie folks !

Leave a Reply

Advertise Here

Photos from our Flickr stream

See all photos

Advertise Here