DotNetNuke 5.6.0 Bug in Google Analytics Module No Hits

The Problem

We found that after updating to DNN 5.6.0 that the hits on Google Analytics dropped to 0 Page Views.

image

We looked at the reason behind the problem with 0 hits being reported. What we found was that the code that Google states we should use on the page (and was working fine in DNN 5.5.1) is now not valid in 5.6.0.

The tracking code for us looks like this:

 

<script type=”text/javascript”>

var _gaq = _gaq || [];
_gaq.push([‘_setAccount’, ‘UA-1111111-1’]);
_gaq.push([‘_trackPageview’]);

(function() {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

When we looked at the rendered source code on the DNN 5.6.0 website, we found that the code was different in the line:

_gaq.push([‘_setAccount’, ‘UA-1111111-1‘]);

Note the “” marks around the ID Number.

So this was someone’s buggy code from DNN Corp.   In the file: SiteAnalytics.config file.

 

The Fix

To fix the problem, is as simple as undoing the buggy code.

in the root directory of your site, is a file called:  SiteAnalytics.config

Open this file in your text editor to reveal:

<?xml version=”1.0″ encoding=”utf-8″ ?>
<AnalyticsEngineConfig>
<Engines>
<AnalyticsEngine>
<EngineType>DotNetNuke.Services.Analytics.GoogleAnalyticsEngine, DotNetNuke</EngineType>
<ElementId>Head</ElementId>
<InjectTop>False</InjectTop>
<ScriptTemplate>
<![CDATA[

<script type=”text/javascript”>
var _gaq = _gaq || [];
_gaq.push([‘_setAccount’, [TRACKING_ID] ]);
_gaq.push([‘_trackPageview’]);

(function() {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
})();
</script>

]]>
</ScriptTemplate>
</AnalyticsEngine>
</Engines>
</AnalyticsEngineConfig>

Just replace the two quotation marks highlighted above “” with single ‘’  one either side of the two [ ]and save the file. This will fix the buggy code.

So the line becomes:

_gaq.push([‘_setAccount’, [TRACKING_ID] ]);

 

Notes on DNN 5.6.1

Originally we suggested that the “” be taken out. We then found after updating the 5.6.1 that the removal of the “” broke that upgrade with regard to Google Analytics. So we have modified these notes to say to replace the “” with single ‘’.

 

Side Note

We stayed stable on DNN 4.9.5 for some time, enjoying not having DNN broken each time we updated. Finally we bit the bullet and with much pain, a Code Expert, a Server Admin Expert and the help of Hyper V rollback capability we updated to DNN 5.x.

Now we are finding ourselves back in the game of undoing crap code every time we run a DNN update. Yes there are some great shiny new features, but we just blew 2 man days working out bugs in the UrlRewriter system and now this analytics bug.

This is disappointing and annoying to again be on this roundabout!

SiteAnalytics – Download File