Wednesday, November 28, 2007

Using Google Analytics with DotNetNuke (DNN)

I use a content management system called DotNetNuke to build a lot of my websites. It's tremendous in its flexibility and power, and {gasp} it's an open source project for the Microsoft platform. I've used other CMS tools, but nothing comes close to the power of DotNetNuke, especially when extending it using ASP.NET.

One problem I've ran into when attempting to use Google Analytics with DNN derives from the fact that each page is built dynamically when the user requests the page. A single default.aspx file is used for all page requests, and the content, skin, objects, etc. are injected as elements into this default.aspx file to create the page. On the surface it would seem simple to just copy and paste the Google Analytics code into this single default.aspx file. Some problems arise from this:

  • Sometimes multiple sites share this default.aspx file. Tracking reports from Google Analytics will then show the numbers for all these sites (or portals as they are called in DNN parlance)
  • Pushing the Google Analytics code into every DotNetNuke page using a single default.aspx file creates an issue with the DNN administrative pages. Not that it hurts anything, but those pages shouldn't be counted in the usage totals - it skews the results.
  • If you have any https pages in your site, they will fail the security test because the Google Analytics code uses plain-jane vanilla http requests. (Note - I've seen some workarounds for this, but none have been satisfactory).
  • The Google Analytics code shows extremely skewed results for some pages because of the strange way that DotNetNuke builds the URLs for each page. The friendly URL problem will hopefully have a fix in a future release.
So what to do? The answer is simpler than it seems.
  1. Login as either the DNN administrator or super user (host) account.
  2. Navigate to your home page
  3. Add a Text/HTML Module, preferable somewhere unobtrusive like the bottom of the page
  4. First, change the settings on the Text/HTML module so that the container is invisible (uncheck the 'Display Container' under the Page Settings section) and save your changes.
  5. Next, click the 'Edit Text' button on the module
  6. In the Edit Text window, click on the 'Source' button to view the actual HTML. Delete whatever content is in there (if any) and copy and paste your Google Analytics code that you received from Google. Make sure to click the Update button to save the changes.
  7. Next, go back into the Settings for the module, but this time expand the 'Advanced Settings' tab. Make sure the 'Show on every page' checkbox is checked and click 'Update'
  8. If you have https pages, navigate to those and manually delete the module from them. You won't be able to track your secure pages (maybe someone has a suggestion about this).
Make sure that Google Analytics is picking up the code, and if so, you'll have to wait until the next day to view your stats through the Analytics reports. Google updates the stats everyday at about midnight Pacific time, so statistics are never real time and always one day behind, but they are a great tool to have.

Happy stats!

24comments:

Ali Nawazsaid...

Such a beautiful solution for DNN Lovers who wana use Google Analytics in theri DNN systems....

Actually I am facing that problem these days because one of my DNN based client wana use Google Analytics, found your page and now I am satisfied with the solution, hope i will got more from your regarding SEO for DNN sites...

I am a relatively new in SEO for DNN sites, previously did little seo of my own site kindly take a look at www.alinawaz.com wana your suggestion on it to make it more powerful...

DUIsaid...

I've never even heard of Dot Net Nuke. Shows you how much I know.

I can't imagine not having G's Analytics though. I have become very addicted to it.

I'll check it out. Thanks for the tip.

:O)

Paulsaid...

Great post thanks for keeping us up to date.

Atlanta Ga Real Estatesaid...

DNN is a cool thing to have going for you. I hear it is a great thing to use for SEO purposes.

Auto insurancesaid...

Great google analytics is great tracking program it will be good to use with dotnetnuke.

Indianapolis Homessaid...

Thanks for the heads up, I often wonder how accurate Analytics really is. I find Hittail to be a great tool also.

Carpet Cleaning NJsaid...

THanks for the info. I love google and all that I can learn for it. This is how I feed my family,

Carpet Cleaners NJsaid...

Google will change things just as we learn them, They always do , Google Analytics is another problem for me, My clients want to use it but I am used to doing what I have been doing..

oyunsaid...

thanks...

Г§ocuk oyunlarД±said...

thanks...

flash gamessaid...

Such a beautiful solution for DNN Lovers who wana use Google Analytics in theri DNN systems....

tatil köylerisaid...

I've never even heard of Dot Net Nuke. Shows you how much I know.

I can't imagine not having G's Analytics though. I have become very addicted to it.

I'll check it out. Thanks for the tip.

oda oyunlarД±said...

I've never even heard of Dot Net Nuke. Shows you how much I know.

I can't imagine not having G's Analytics though. I have become very addicted to it.

I'll check it out. Thanks for the tip.

otellersaid...

Such a beautiful solution for DNN Lovers who wana use Google Analytics in theri DNN systems

Jamaica Cruisesaid...

Man.... is this site dead? I wish you would come back soon.

:O(

dui forumssaid...

My G analytics has been messing up for 2 days. Anyone else seeing the same?

contributory negligencesaid...

G analytics has been acting screwy for me for a while now. I think G is having some budget problems maybe?? lol

Relocating To Atlantasaid...

Actually I am facing that problem these days because one of my DNN based client wana use Google Analytics, found your page and now I am satisfied with the solution, hope i will got more from your regarding SEO for DNN sites...

Anonymoussaid...

I used this solution and am waiting to see if Google picks up the data - will take a few hours. However, when looking closer at Google's instructions, they tell you to put the tracking code in the head tag, before the body tag. When using this solution, the code ends up in the header of the module, but the module is contained within the body tag, so the javascript ends up being placed within Body. Does GA still pick up the data feed this way? Looking at the source code, it certainly doesn't show up in the head tag, but perhaps it ends up there and is processed by the browser as a head tag component on the fly.

Hopefully it works! Thanks for the tip.

online credit reportsaid...

DNN rocks man. I've been using it around 6 months or so. It has seriously saved me a lot of time.

inventory softwaresaid...

I've never even heard of it. Dot Net Nuke sounds pretty cool. I;ll give it a try if it;s free.

wicked ticketssaid...

I don't know man. I just can't stand dnn.

football jerseyssaid...

DNN is cool.

Sexy Asian Girls and Babessaid...

Hmm DNN sounds like it would be a pretty good alternative to Joomla. In any case I'm still waiting for Adsense support for Google Analytics, the free scripts out there don't really do the job for me.