Santry Enterprises posted on July 17, 2010 07:14
Some may have noticed that Google Analytics isn't working anymore in your DNN site. You have the right tracking ID in your set up, but it just isn't working.
Google changed things over late last year to use an optimized code to allow for faster page downloads. In the past, your page would have to wait for the script to complete loading in order to render the page, now it's asynchronous. Even so, most DNN installs use the old way.
Fortunately, DNN is very extensible, and you can that by changing the SiteAnalytics.config which is located in the root of your site.
Open the file and you can see the XML that defines the analytics engine, you don't just have to put Google in here, if you have some else, you can see it's pretty easy to modify to accommodate any engine.
Below is the modified code to apply the new analytics method from Google. As you can see though, you could define any amount or type of engines in the file, just describe the engine, where you want the code to placed (in here, the header section), and then the script itself.
<?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',]PAGE_URL[]);
(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';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
})();
</script>
[]>
</ScriptTemplate>
</AnalyticsEngine>
</Engines>
</AnalyticsEngineConfig>