Products

Solutions

Resources

Partners

Community

About

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

The Community Blog is a personal opinion of community members and by no means the official standpoint of DNN Corp or DNN Platform. This is a place to express personal thoughts about DNNPlatform, the community and its ecosystem. Do you have useful information that you would like to share with the DNN Community in a featured article or blog? If so, please contact .

The use of the Community Blog is covered by our Community Blog Guidelines - please read before commenting or posting.


Using Google Tag Manager with Dnn

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.

Comments

Jack Vinitsky
I believe, the GTM ID is unique to each TLD/web site. As such this doesn't seem like it would work with multi-portal installations of Evoq or DNN, correct?
Jack Vinitsky Wednesday, September 23, 2015 4:05 PM (link)
Winston Haybittle
Thanks for article, this is super interesting, I'm going to experiment with this
Winston Haybittle Wednesday, September 23, 2015 5:12 PM (link)
Bruce Chapman
@Jack - yes, you're right and something I completely forgot to address in my original post. I have updated the post to show how you can leverage the GA module Token Replacement to supply a correct GTM ID per individual site where the domain names are different. Doing it this way means you can absolutely support different GTM accounts for multi-site installations.
Bruce Chapman Wednesday, September 23, 2015 8:55 PM (link)
Erik Hinds
Is this solution "Upgrade Proof".

Typically, I have included GTM in a skin object and that has worked well. The skin object's code behind places the script in the opening body. I like your option better, but only if it is not overwritten by an upgrade.
Erik Hinds Thursday, September 24, 2015 10:45 AM (link)
Brian Dukes
@Erik, this won't be overwritten by an upgrade.

@Bruce, you may also want to note that the setting to inject into the top of the body will cause folks to run into DNN-7047 (fixed in 7.4.2), which breaks post backs throughout the website.
Brian Dukes Thursday, September 24, 2015 5:12 PM (link)
Bruce Chapman
@Brian - I wasn't aware of that issue, thanks for raising it.
Bruce Chapman Thursday, September 24, 2015 5:36 PM (link)
rudgr
any ETA on DNN 7.4.2 ? tx
rudgr Monday, September 28, 2015 7:04 AM (link)
Lennard van Diggelen
Ok so it should be in 7.4.2 but when I go to Admin > Google analytics, there is no GTM option or enable checkbox???
Lennard van Diggelen Wednesday, October 7, 2015 4:05 AM (link)
cathal connolly
@Lennard -that's expected. Bruce's screenshot shows Google Analytics Pro (which is part of Evoq). In DNN Platform, the Google Analytics module only has 3 settings:
Tracking ID
URLParameter:
Track For Administrators?
cathal connolly Wednesday, October 7, 2015 7:11 AM (link)
Bruce Chapman
@Lennard - all that matters is that you have the right value in the siteanalytics.config, and that you put the GTM Tracking ID in the TrackingID box in the UI. That is the important part of the process.
Bruce Chapman Wednesday, October 7, 2015 6:21 PM (link)
Lennard van Diggelen
@Cathal & @Bruce
Thanks! it indeed works now.

Though I find it strange that the article is insinuating that it works the Evoq way which is kind of confusing.
I would recommend to revise this article with an annotation of the way it is described by you. Especially when we are talking about an Analytics module and we are implementing Google Tag Manager.

Lennard van Diggelen Thursday, October 8, 2015 5:15 AM (link)
Pieter-Jan
Up to now I have been adding the GTM script directly in the default.aspx file after the open tag.
Is this upgrade proof? I am assuming not.

It would be nice if the Analytics module ("pro" and normal) would allow you to enter the GTM ID and GTM script in the module, eliminating the need to edit the siteanalytics.config or dafault.aspx files.
Pieter-Jan Monday, November 2, 2015 7:43 AM (link)
Bruce Chapman
@Pieter-Jan - adding the script directly in the default.aspx is not upgrade proof as it will be overwritten with each upgrade.

It wouldn't make sense to change the Analytics module to support a GTM id, instead it would be possible to create a specific GTM module- someone in the community may do that. However, adding the script into the Analytics module works for those who want to use GTM.
Bruce Chapman Monday, November 2, 2015 5:14 PM (link)
Pieter-Jan
@Bruce. Thanks. Will put it in the siteanalytics.config file going forward.
Pieter-Jan Monday, November 2, 2015 8:59 PM (link)
Pieter-Jan
@Bruce I do "monkey-see-money do coding" so I just want to clarify a few things.

1) It looks like the Google Tag Manager script that you copy and past is standard, except for the GTM code.
Are the any reasons why I could not prepare a SiteAnalytics.config "tempalte" with the [TRACKING_ID] and then just upload that file to each new DNN site.
Then I would just enter the GTM-XXXX code in the Analytics module in Admin.

2) I have followed the steps as described in the blog. The GTM and Analytics seems to work.
However, when using GTM in Webmaster to verify the site, Webmaster tools gives an error saying that it has found the GTM code, but that it is not in the correct location.
It seems that Webmaster tools want it DIRECTLY after the opening Body tag and does not like the script before it.

I eventually verified the website by placing an HTML tag in the Home Page Header Tags.
Pieter-Jan Thursday, November 5, 2015 8:31 PM (link)
Bruce Chapman
@Pieter-Jan - yes you can use the same file for all installations, and update the GTM value in the tracking Id for each site.

Webmaster tools might complain about that, but otherwise it shouldn't impact the running of the GTM code. It is probably quite a 'dumb' check and errs on the side of caution if trying to validate a page. Using the Html Tag is the easy way to go.
Bruce Chapman Monday, November 9, 2015 6:01 AM (link)
Ben Wiese
Morning Guys,
We followed these instructions earlier in the week and ran into some conflict issues that are above my coding/dnn knowledge.

Here's the scenario:
Previously we were using content injection for Universal Google Analytics.

Followed steps above and got tag manager working successfully, however,
-LiveTabs started was showing incomplete info (couldn't edit any other tabs)
- Unable to add new pages (same page reloads)
- Content Injection Module was showing blanks on all injections

Any ideas or what the conflict could be. We reverted to universal analytics. Thanks for any insight and help!
Ben Wiese Friday, January 8, 2016 11:24 AM (link)
Lennard van Diggelen
@Ben Wiese

LiveTabs is an 3rd party module so I think you won't find any support here with that. sorry :(. Maybe Mandeeps can help you with this? They have great support.

But to respond to your comment I have a feeling that there is a JS-error that conflicts within DNN, seen the issues you describe. Can you provide more info like "console errors" in the browser?
Lennard van Diggelen Monday, January 11, 2016 4:21 AM (link)
Brian Dukes
@Ben, I think you're probably running into the issue I mentioned in my comment above. You can upgrade to DNN 7.4.2, or you can change InjectTop to false.
Brian Dukes Wednesday, January 13, 2016 4:12 PM (link)
M Bouwman
Another addition, make sure you set:

Body
True

M Bouwman Friday, July 15, 2016 4:12 AM (link)
Robert-Jan Kuyper
This solutions is actually update proof. You can use it for all the websites in your portal. In GTM you can create for each website a new container and use a lookup-table to let user data go to the right property.
Robert-Jan Kuyper Wednesday, November 9, 2016 5:14 AM (link)
weweave UG
For anyone how wants to set up Google Tag Manager without any coding or modifying DNN's config files should check out our module DNN Google Tag Manager (https://weweave.net/s/dnn-google-tag-manager).
weweave UG Sunday, January 8, 2017 7:14 AM (link)
Tony Roberts
GTM states that part of the code is for the head section and the other is for the body section. Your method pastes it all in the body section. Will that cause any issues?
Thx
Tony Roberts Friday, March 9, 2018 2:55 PM (link)
rudgr
Hi,

Seems that this GTM configuration re-introduces an old bug in DNN 9.2.0 that module settings cannot be saved?

https://dnntracker.atlassian.net/browse/DNN-5715

from browser console:

Uncaught Error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
at Function.Error.create (ScriptResource.axd:5)
at Sys.WebForms.PageRequestManager._createPageRequestManagerServerError (ScriptResource.axd:5)
at Sys.WebForms.PageRequestManager._parseDelta (ScriptResource.axd:5)
at Sys.WebForms.PageRequestManager._onFormSubmitCompleted (ScriptResource.axd:5)
at Array. (ScriptResource.axd:5)
at ScriptResource.axd:5
at Sys.Net.WebRequest.completed (ScriptResource.axd:5)
at XMLHttpRequest._onReadyStateChange (ScriptResource.axd:5)

admin log:

AbsoluteURL:/Default.aspx

DefaultDataProvider:DotNetNuke.Data.SqlDataProvider, DotNetNuke

ExceptionGUID:c3870384-e755-4298-a69a-fa10aee468b4

AssemblyVersion:9.2.0

PortalId:0

UserId:1

TabId:90

RawUrl:/About/ctl/Module/ModuleId/423?ReturnURL=/About&popUp=true

Referrer:https://domain.io/About/ctl/Module/ModuleId/423?ReturnURL=/About&popUp=true

UserAgent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36

ExceptionHash:opnkyUkum0BySFIwc4QSjf6wbgs=

Message:Object reference not set to an instance of an object.

StackTrace:

InnerMessage:Object reference not set to an instance of an object.

InnerStackTrace:

at DotNetNuke.Security.Permissions.PermissionController.<>c__DisplayClass8_0.b__0(PermissionInfo p) at System.Linq.Enumerable.WhereListIterator`1.MoveNext() at System.Linq.Buffer`1..ctor(IEnumerable`1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) at DotNetNuke.Security.Permissions.PermissionController.GetPermissionsByModule(Int32 moduleId, Int32 tabId) at DotNetNuke.Security.Permissions.Controls.ModulePermissionsGrid.GetPermissions() at DotNetNuke.Security.Permissions.Controls.PermissionsGrid.CreateChildControls() at DotNetNuke.Security.Permissions.Controls.ModulePermissionsGrid.CreateChildControls() at System.Web.UI.Control.EnsureChildControls() at System.Web.UI.Control.FindControl(String id, Int32 pathOffset) at System.Web.UI.Control.FindControl(String id, Int32 pathOffset) at System.Web.UI.Control.FindControl(String id, Int32 pathOffset) at System.Web.UI.Control.FindControl(String id, Int32 pathOffset) at System.Web.UI.Control.FindControl(String id, Int32 pathOffset) at System.Web.UI.Page.FindControl(String id) at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Source:

FileName:

FileLineNumber:0

FileColumnNumber:0

Method:

Removing gtm configuration "fixes" the issue...

tx

Rutger

rudgr Tuesday, April 3, 2018 7:02 AM (link)

Comment Form

Only registered users may post comments.

NewsArchives


Aderson Oliveira (22)
Alec Whittington (11)
Alessandra Daniels (3)
Alex Shirley (10)
Andrew Hoefling (3)
Andrew Nurse (30)
Andy Tryba (1)
Anthony Glenwright (5)
Antonio Chagoury (28)
Ash Prasad (37)
Ben Schmidt (1)
Benjamin Hermann (25)
Benoit Sarton (9)
Beth Firebaugh (12)
Bill Walker (36)
Bob Kruger (5)
Bogdan Litescu (1)
Brian Dukes (2)
Brice Snow (1)
Bruce Chapman (20)
Bryan Andrews (1)
cathal connolly (55)
Charles Nurse (163)
Chris Hammond (213)
Chris Paterra (55)
Clint Patterson (108)
Cuong Dang (21)
Daniel Bartholomew (2)
Daniel Mettler (181)
Daniel Valadas (48)
Dave Buckner (2)
David Poindexter (12)
David Rodriguez (3)
Dennis Shiao (1)
Doug Howell (11)
Erik van Ballegoij (30)
Ernst Peter Tamminga (80)
Francisco Perez Andres (17)
Geoff Barlow (12)
George Alatrash (12)
Gifford Watkins (3)
Gilles Le Pigocher (3)
Ian Robinson (7)
Israel Martinez (17)
Jan Blomquist (2)
Jan Jonas (3)
Jaspreet Bhatia (1)
Jenni Merrifield (6)
Joe Brinkman (274)
John Mitchell (1)
Jon Henning (14)
Jonathan Sheely (4)
Jordan Coopersmith (1)
Joseph Craig (2)
Kan Ma (1)
Keivan Beigi (3)
Kelly Ford (4)
Ken Grierson (10)
Kevin Schreiner (6)
Leigh Pointer (31)
Lorraine Young (60)
Malik Khan (1)
Matt Rutledge (2)
Matthias Schlomann (16)
Mauricio Márquez (5)
Michael Doxsey (7)
Michael Tobisch (3)
Michael Washington (202)
Miguel Gatmaytan (3)
Mike Horton (19)
Mitchel Sellers (40)
Nathan Rover (3)
Navin V Nagiah (14)
Néstor Sánchez (31)
Nik Kalyani (14)
Oliver Hine (1)
Patricio F. Salinas (1)
Patrick Ryan (1)
Peter Donker (54)
Philip Beadle (135)
Philipp Becker (4)
Richard Dumas (22)
Robert J Collins (5)
Roger Selwyn (8)
Ruben Lopez (1)
Ryan Martinez (1)
Sacha Trauwaen (1)
Salar Golestanian (4)
Sanjay Mehrotra (9)
Scott McCulloch (1)
Scott Schlesier (11)
Scott Wilkinson (3)
Scott Willhite (97)
Sebastian Leupold (80)
Shaun Walker (237)
Shawn Mehaffie (17)
Stefan Cullmann (12)
Stefan Kamphuis (12)
Steve Fabian (31)
Steven Fisher (1)
Tony Henrich (3)
Torsten Weggen (3)
Tycho de Waard (4)
Vicenç Masanas (27)
Vincent Nguyen (3)
Vitaly Kozadayev (6)
Will Morgenweck (40)
Will Strohl (180)
William Severance (5)
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out