My Cart (0)  |  My Orders  |  My Downloads  |  My Auction  |  My Account  |  Help


Login |Register        Search

How to Use Google Tag Manager with DNN

                Print      Add To Favorite     Add To Watch List     Contact Author

Creator: host   6/7/2016 11:05:43 PM    Author: Bruce Chapman   Source: http://www.dnnsoftware.com/community-blog/cid/155268/using-google-tag-manager-with-dnn   Views: 1706    0    0  
Tags:
DNN 8 Google Tag Manager

Google Tag Manager (GTM) is a tool which allows a website owner to quickly integrate different script-based products into a website without needing to edit the underlying pages of the site.   While ‘tag’ in this context can be confusing to some, it means ‘Html Tag’ rather than ‘Taxonomy Tag’.    Google Tag Manager is a way of including different Html Tags into your site without needing to edit each page to add them.   The most common use case is to add the Google Analytics script tag which tracks the pageviews and other interactions on a page. 

The traditional way to add Google Analytics (and the example shown when you sign up to a new Analytics account) is to edit your website to include a script tag which contains the snippet used by Google to track the pageview and events which occur while the page is being viewed.   Google Tag Manager replaces that by adding a GTM script tag instead.  When the page is loaded, this then calls back to your GTM account and loads any scripts dynamically.   You can then use the GTM console (https://tagmanager.google.com/) to add various pre-defined products or to create your own tags.

In essence, GTM acts as a type of Content Manager for externally linked products that use script tag includes.  This is especially helpful for those who cannot easily edit the files on their own website, such as where a Marketing team owns the analytics and tracking of a site, but an IT team owns the files or application.   GTM resolves when the site is run, meaning that changes can be quickly made without any changes to the underlying system.

This is less of an issue with DNN because DNN allows easy editing of pages without the need for getting a technical resource involved, but I have been asked several times by people how to include the GTM tracking script in DNN, specifically as a way to manage their Google Analytics account.  So here’s an easy way to do that.

Using the DNN Google Analytics Module to add GTM Script

Dnn ships with a ‘Google Analytics’ module, and Evoq Content and Evoq Engage ship with a ‘Google Analytics Pro’ module.   This works by injecting the GA script onto each page of the site, and merging the UA-xxyyzz-nn User Account Id with the script.   While most people use this just for Google Analytics, it can easily be used to inject the GTM script instead.  Here’s how:

1.  Sign up for a GTM account at https://tagmanager.google.com/ if you haven’t done so already.   Find the location of the Tracking Script – you can click on the account identifier (it will look like GTM-AABBCC).  The tracking script is a chunk of Html script tags.

2.  Make sure you’re using the Google Analytics module by accessing it under Admin->Google Analytics or Admin->Google Analytics Pro if using Evoq.  You should have the ‘Enable’ checkbox checked.

3.  Open the ‘SiteAnalytics.Config’ file which is in the root folder of your Dnn installation in a text or Xml editor.  Notepad is fine if you don’t have anything more fancy. 

4.  Paste the GTM tracking script into the Xml element in the SiteAnalytics.Config file.  It should go between the opening and closing tags.  Here’s an example:

Dnn Google Tag Manager Script Include

5.  Change the options in the Xml file for   to equal ‘Body’, and to equal ‘True’.  This injects the script at the start of the ‘body’ tag as per Google recommendations for GTM.

6.  Save the SiteAnalytics.config and refresh one of the pages of your sites.  Check the page source using your browser tools and verify that the GTM script tag is appearing.

UPDATE : Working with Multi-Site Installations

As Jack Vinitsky points out in the comment below, this locks an entire Dnn installation to a single GTM account, whereas GTM accounts are typically site/domain specific.  If you have multiple sites in your DNN installation, and you want to use GTM in each site, you’ll need a slightly different solution. 

This is easy to do, because the GA module being used here has to solve the exact same problem.   Here’s how you do it:

Step 1 : In your Admin->Google Analytics or Admin->Google Analytics Pro (Evoq editions) enter the GTM ID (in the posted example, it’s GTM-MRGHSJ)

Google Tag Manager ID in tracking ID DNN

Step 2 : In your SiteAnalytics.config file, after pasting the snippet directly from the GTM console, replace the ‘GTM-XXYYZZ’ ID with the [TRACKING_ID] token

GTM property ID in the Tracking ID token DNN

Step 3 : Save and check your work by looking at the Html source for the site in question:

The GTM ID will be substituted into where the [TRACKING_ID] token is.  This will be done for each Site in the DNN installation where the module is enabled and has the specific GTM ID inserted in the Admin->Google Analytics / Google Analytics Pro screen.

Thanks to Jack for pointing out this oversight in my original post.

Working with GTM

Once you have the GTM script set up and working, you can then add different tags and events via the GTM console.  Remember to ‘Publish’ each change before checking that the added tags are working.

Have you got experience with using GTM and DNN?  Do you like it and find it gives advantages to manually including different scripts?  Let me know via the comments.


Rating People: 0   Average Rating:     

     DnnModule.com is built to provide DNN quality modules and DNN skins, some of them are free, some not. We wish these stuffs (free or not ) can be useful to you.

     Besides that, we also provide a full range of professional services, ranging from web site build, seo, system management, administration, support, senior consultancy and security services. We act as if your development project or network was ours, with care and respect. We are not satisfied until it works the way you want it to, and we don't silently ignore found issues as somebody else's problem.