MyLifeBBS

The world with no boundaries

  • Home
  • Google Apps
  • DotNetNuke
  • Things in The Internet
  • SEO
  • Contact Me
  • PostsComments

Implementing Google Analytics Asynchronous Snippet in DotNetNuke – the simple ways.

October 20, 2010 by George

UPDATE: The method below does not work anymore. You’re advised to upgrade your DNN to version 5.6.1 or above for fool proof solution.

Recently, Google Analytics launched its third generation of tracking script that fully support asynchronous loading which speed up the page rendering speed of modern browsers. If you use Google Page Speed tool to analyze your web page that is using old snippet, you will see something like below

asynchronously-load

Implementing Google Analytics always a bit tricky and become every ‘messy’ if you’re using old type of module insertion on every pages.

Here’s the 3 simplest ways to implement Google Analytics:

1. Edit the SiteAnalytics.config file. Since version 5, DotNetNuke shipped with core Google Analytics module which located under Admin section. If you entered your tracking ID, the config file will be loaded into your web pages.

By default, the script will be loaded just before </body> tag. The asynchronous however highly suggest us to put the snippet just before </head> tag.

To do this, we need to customize the SiteAnalytics.config file a bit to look like this:

<?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>

Note: make sure to change the value of ElementId tag from body to head.

<ElementId>Head</ElementId>

And that’s it!

Btw, the config file is located in the root of your DNN installation. Here’s a copy of the above sample, you’re safe to replace it directly…

 

2. Second method basically is to put the snippet into default.aspx file. Both methods has a limitation where you cannot exclude it from certain pages or user role like administrator.

3. While third method is to get some third party modules (which most of it still running older generation of snippet) that support custom role filtering .

Filed Under: DotNetNuke Tagged With: Implementing Google Analytics in DotNetNuke

Recommended DNN Modules

SiteGround Hosting Fast and Reliable WordPress hosting that we recommend.
XMOD Pro is a very good module to create complicated forms with external database writing. You could use it to build a simple module as well. The drawbacks like custom permission and filtering might be an issue though.
Ultra Video Gallery is a very advanced multimedia module which allows you to create a site near to YouTube. It allows you to convert video directly in the website, share it, comment, membership integration and so on.
Project Management Templates, This is not a DNN module but if you need to manage your works better, try the project management templates. It helps a lot.

Post Archives

Blogroll

  • Food Promotions in Kuala Lumpur GoEatOut Promotion Page

Recommended Sites

  • DNN Store is the best place to shop for DNN modules
  • Malaysia Food Guide Best place to find malaysia food promotions and place to eat.
  • Malaysia Public Holidays A site that list out all public holidays in Malaysia with lunar calendar too

Recent Comments

  • kenny on How to modify DNN 6 login module skin design – Quick Guide
  • michelle on Turn back On Windows 8 Wifi – 100% works
  • Oracle9 on Turn back On Windows 8 Wifi – 100% works
  • AK on Turn back On Windows 8 Wifi – 100% works
  • Customizing the DotNetNuke login page : Karl’s Place on DotNetNuke Customizing your Login – PART 3

About the Author

I'm the founder of InnoChannel Sdn Bhd. We're here to help people to market their business online and also a Google Apps Premier Partner in Malaysia who provides email consultation, setup, data migration and so on.

Copyright © 2023 · News Pro Theme on Genesis Framework · WordPress · Log in