Learn More





DNN Community Blog

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 ( 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 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.


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)
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 07, 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
Track For Administrators?
cathal connolly Wednesday, October 07, 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 07, 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 08, 2015 5:15 AM (link)
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 02, 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 02, 2015 5:14 PM (link)
@Bruce. Thanks. Will put it in the siteanalytics.config file going forward.
Pieter-Jan Monday, November 02, 2015 8:59 PM (link)
@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 05, 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 09, 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 08, 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:


M Bouwman Friday, July 15, 2016 4:12 AM (link)

Comment Form

Only registered users may post comments.


2sic Daniel Mettler (124)
Aderson Oliveira (15)
Alec Whittington (11)
Alex Shirley (10)
Andrew Nurse (30)
Anthony Glenwright (5)
Antonio Chagoury (28)
Ash Prasad (22)
Ben Schmidt (1)
Benjamin Hermann (25)
Benoit Sarton (9)
Beth Firebaugh (12)
Bill Walker (36)
Bob Kruger (5)
Brian Dukes (2)
Brice Snow (1)
Bruce Chapman (20)
Bryan Andrews (1)
cathal connolly (55)
Charles Nurse (163)
Chris Hammond (203)
Chris Paterra (55)
Clinton Patterson (28)
Cuong Dang (21)
Daniel Bartholomew (2)
Dave Buckner (2)
David Poindexter (3)
David Rodriguez (2)
Doug Howell (11)
Erik van Ballegoij (30)
Ernst Peter Tamminga (74)
Geoff Barlow (6)
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 (270)
John Mitchell (1)
Jon Henning (14)
Jonathan Sheely (4)
Jordan Coopersmith (1)
Joseph Craig (2)
Kan Ma (1)
Keivan Beigi (3)
Ken Grierson (10)
Kevin Schreiner (6)
Leigh Pointer (31)
Lorraine Young (60)
Malik Khan (1)
Matthias Schlomann (15)
Mauricio Márquez (5)
Michael Doxsey (7)
Michael Tobisch (3)
Michael Washington (202)
Mike Horton (19)
Mitchel Sellers (28)
Nathan Rover (3)
Navin V Nagiah (14)
Néstor Sánchez (31)
Nik Kalyani (14)
Peter Donker (52)
Philip Beadle (135)
Philipp Becker (4)
Richard Dumas (22)
Robert J Collins (5)
Roger Selwyn (8)
Ruben Lopez (1)
Ryan Martinez (1)
Salar Golestanian (4)
Sanjay Mehrotra (9)
Scott McCulloch (1)
Scott S (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)
Timo Breumelhof (24)
Tony Henrich (3)
Torsten Weggen (2)
Vicenç Masanas (27)
Vincent Nguyen (3)
Vitaly Kozadayev (6)
Will Morgenweck (37)
Will Strohl (163)
William Severance (5)
Try Evoq
For Free
Start Free Trial
a Demo
See Evoq Live
Need More Information?