Here's how you can configure Google Analytics in DNN 9.3.1+
- Log in as the Admin or with a SuperUser account
- Hover over the "Settings" gear icon
- Click "Connectors"
- You will see "Google Analytics" and a "Connect" button if you haven't configured this yet. (If it's already configured, you will see an "Edit" button)
- Click the Connect (or Edit) button and the interface will slide down.
- Input your Tracking ID. It will probably look something like UA-XXXXX-Y. I leave the URL Parameter field blank and then uncheck "Track for Administrators" and then click Save.
- Once it saves, you can close the Connectors panel.
- Verify the code is working in your Google Analytics dashboard.
Note: If you deselected "Track for Administrators", the code won't appear in the source if you're logged in as a SuperUser or Admin. So check that the code is in the source by using a different browser or log out and check.
If you only wanted to use Google Analytics and you're using DNN 9.3.1+, then you can stop reading here. If you're interested in how it works, or you want to implement Google Tag Manager, then read on.
Here's how it works behind the scenes
There are two files at play:
- /Root/Portals/<portal-folder>/GoogleAnalytics.config > This is where the Tracking Code lives. When you update the Tracking ID through the Connectors interface, this is the file that is created and then updated. If you're using a version of DNN9 that is pre-9.3.1, you have to create and edit this file directly through FTP as there is no Connectors interface in those versions of DNN9.
- /Root/SiteAnalytics.config > This is the instance-wide template for the tracking code. This template is applied to the entire instance so if you change it, it will affect ALL portals on your instance. You need FTP to access and edit this file. If you're using Google Analytics, you don't need to change anything. But if you're using Google Tag Manager, you need to update this file so that it uses the Google Tag Manager code. Just be mindful of the [TRACKING_ID] token as that token is replaced by the Tracking ID in the GoogleAnalytics.config file.
How to change your entire DNN instance to use Google Tag Manager
Please note! To use Google Tag Manager, you will need to edit the SiteAnalytics.config to update the template to handle the Tracking ID differently. However, please know that changing the SiteAnalytics.config template to use Google Tag Manager affects ALL portals on the instance. So if you a multi-portal instance, please be aware that you're affecting all portals. If all of your portals are using or going to use Google Tag Manager, then you should be fine. If you have a mix between Google Analytics and Google Tag Manager, it would be best to leave it as the default Google Analytics tracking code and then handle the Google Tag Manager templates differently.
Now that you know that, here's how you update your DNN instance to use Google Tag Manager code:
- Follow the steps above and go to Connectors > Google Analytics and input your Tracking ID and save it. If you're using pre-9.3.1, create and edit the portal file GoogleAnalytics.config.
- Then open the file /Root/SiteAnalytics.config using FTP, and edit it to use the Google Tag Manager code that you were provided by Google. Make sure to replace to the tracking ID with the token [TRACKING_ID] so that it references each portal's GoogleAnalytics.config file.
Here's what it should look like:
- Save and upload the file.
I hope that provide insight into Google Analytics and Google Tag Manager in DNN 9.3.1+. If you're looking for more help with getting the most out of your DNN website, please check out my page for Expert DNN Development. I'm always looking to help businesses with DNN websites to improve their DNN experience.