Google Analytics is great. A free, fully featured website tracking and reporting system. It's even better if you use Google Adwords and want to test out how different ads work with getting visitors. DotNetNuke is great. A free, fully featured web platform in which the sky is the limit for developing websites quickly and easily. What I found, though, was that putting the two together, while not difficult, is quite clunky. So, I set out to create a much better way.
Enter the DotNetNuke Google Analytics module - a free and easy way to integrate the two together.
The DotNetNuke Google Analytics module
The Google Analytics module is a 'normal' DotNetNuke module, so if you have admin permissions on your DotNetNuke website to install modules, then you can install this one. It doesn't use any database tables or web.config modifications, so should be OK for anyone on shared hosting to use. It is a lightweight module, and is designed not to place extra load onto the website.
How to hook up Google Analytics to your DotNetNuke website
Step 0: Create and/or locate your login details for your Google Analytics account. If you haven't already got an account, follow the instructions on the Analytics site to create an account and website profile (http://analytics.google.com).
Step 1: Download the Module install Zip file from this page.
Step 2: Install the module by using the 'Module Install' functionality in your DotNetNuke portal. To check that the module installed correctly, it should appear in the 'Module' drop down list in your Control Panel, under the name "iFinity Google Analytics".
Step 3: Go to the home page of your DotNetNuke portal, and use the 'Add New Module' functionality to add an instance of the iFinity Google Analytics module to the page. I normally use the bottom pane to keep it out of the way of other modules. Don't be worried that you can see the module in 'Edit' mode. The module will disappear when you log out as Administrator.
Step 4: Click on the 'Settings' control for the Google Analytics module you just created. Then, scroll the Settings page until you get to the 'Advanced Settings' section, and check the 'Display Module on All Pages'. This ensures that all pages on your website are tracked by Google Analytics.
See the red highlighted area:
Advanced Settings section of the DotNetNuke module
If for any reason, you didn't want all pages on your site to be tracked, you can just copy the module from the home page onto the pages you want tracked. Scroll further down the page, expand the 'Page Settings' section until you get to the 'Basic Settings' section, and select Visibility: None, and make Display Container unchecked. This hides the Google Analytics module from visitors.
See the red highlighted area:
Basic Settings section of the DotNetNuke module
Step 5: Scroll down the page further until you reach the 'Analytics Script Generator Settings' section. Under here is the specific settings for your site. Leave this page for a minute and open up a new browser window to go to Google Analytics.
See the following example:
Analytics Settings section of the DotNetNuke Module
Step 7: (optional) If you'd like to restrict tracking so that it doesn't show on the reports for certain visitors, you can select a DotNetNuke security group in the next drop down list. For example, you don't want the administrative editing to show up as page hits on Google Analytics. In that case, you would select 'Administrators' as the group to exclude from tracking.
Step 8: Click on Update. The page should refresh and return to the home page of your site. If you do a "View Source" on your browser and scroll to the bottom of the HTML, just before the
body tag, you should see the generated script. (Note: if you selected the Adminstrator group, you'll have to sign out first).
Step 9: Go back to your Google Analytics account. It should still be on the page showing the tracking code to be added. Click on the 'Finish' button at the bottom. When it returns to the website profile page, you should see a green tick and the words 'Receiving Data'. If you do see this, your site is providing statistics to Analytics and you are all set.
The security group option is there so that any editing and other administrative activity doesn't show up on the Analytics reports. However, if you wanted to separate out usage for, say, registered vs. non-registered users, you can set up two profiles in Analytics and create two Analytics modules in your DotNetNuke site. You can then set one to track unregistered users by excluding registered users. and vice versa. The other box on the settings page is the 'Do not generate tracking script for calls to this host'. This option allows you to interrupt calls to Google when the site is called using a specific host-name. I normally use this so that when running tests on localhost, I'm not bothering the Google server. However, instead of totally hiding the code, all that happens is that the
So how does it work?
RegisterClientScript' ASP.NET call. And, that's it.
About the only tricky bit is the use of a created
BasePage property, a trick I learnt from Scott McCulloch of www.ventrian.com.au. By creating this property inside a class which is derived from
PortalModuleBase, you can get access to all sorts of goodies like the meta tags, headers, and the base
ClientScript object for the page.
public DotNetNuke.Framework.CDefault BasePage
- First version : 27th August 2007.