Categories: Google Analytics

Google Analytics has been around since 2005. Google Tag Manager was introduced in 2012. It provides webmasters and marketers with a way to quickly add, replace and modify code snippets in one place without needing access to the website code each time. So, we need to add the code for Google Analytics to track site visits, but then 4 months later, we want to add code to track the site for Dynamics 365 for Marketing, or ClickDimensions. If Google Tag Manager is being used, we can just add the code in tags there rather than on the website. For argument’s sake, the Google Analytics Series COULD have started with this blog post… but I wanted to give you a few posts first to start getting set up with data. Plus, not everyone actually needs to use it if all they want to ever do is just track site visits and not do anything cool… but who wants that?

To get started, visit and add a new account. Create a container, which you can call whatever you like, and set the target platform as Web. Then click Create.

Just like we did with Google Analytics, we get some code to add for Google Tag Manager. So we (or your webmaster) needs to add this in two places. Likely you have a header file where this can be added, but you will have code to add in the <head> section and code to add right after the opening <body> tag. Although the Google Analytics code you have there isn’t needed, don’t remove it just yet.

Once this has been done click on the Variables link from the left navigation and add a new User-Defined Variable. Pick a variable type of Google Analytics settings.

Now we need to configure the variable by adding in your unique Google Analytics Tracking Id. To get this, go in to the Admin area of Google Analytics, then the Property, then Property Settings. The Tracking Id will be right at the top. Copy the id and paste in to the field on your new variable.

Next, we need to add a new tag which we can do by navigating to the Tag section from the left navigation, or from the top left of the overview dashboard. Select the Tag Type of Google Analytics: Universal Analytics. The Track Type is Pageview. From the Google Analytics settings drop down list, you should see {{Google Analytics ID}}. This is the variable we added above. Select this from the list. In the Triggering section, select All Pages.

Once you’ve saved this tag, you should notice there are some Workspace Changes. Don’t submit them just yet. Instead, click on Preview. This will put your workspace in to a preview mode.

Now simply go and open up a new tab in your browser and open up your website. The bottom half of the side should now show a new panel across it. You need to look at the tags summary and in the tags fired section, make sure your Google Analytics Tracking Code fired. This means everything has been installed correctly, and your site visits will continue to be tracked.

Once you’ve confirmed the tag fired, submit the changes, and add some notes for audit purposes as to what we changed. You should now be able to remove the original Google Analytics tracking code added to your site.

If we need to add new tags, like the Dynamics 365 Marketing App tracking code I mentioned, we can simple add a new Custom HTML Tag and paste in the HTML. The triggering will again be on all pages.

Want to just watch how to do this? Check out the video:

Check out the latest post:
Send Unique Event Registration Response Emails For Each Event Using No Code

This is just 1 of 448 articles. You can browse through all of them by going to the main blog page, or navigate through different categories to find more content you are interested in. You can also subscribe and get new blog posts emailed to you directly.

6 thoughts on “Part 6 – Using Google Tag Manager To Combine Your Tracking Code In One

  1. Hi Megan,

    If i add microsoft’s javascript snippet for Dynamics Marketing to our GTM, will that data be available to view within our Dynamics Tenancy?

    Or will it only provide feedback through Google Analytics?

    1. Hi Simon, yes, you can totally do that. In fact, if you are using Google Tag Manager, I would suggest putting all of your snippets there. So you would need to add a new Tag, with the firing trigger of All Pages. The type would be Custom HTML. You would then just paste in the JavaScript snippet you get from the D365 Marketing App, and that’s it! You should then start to see your insights for the Marketing Website populate in D365 Marketing. Hope that helps!

  2. Hi Megan, maybe you can help me. I am trying to find the solution, which would allow me to track the traffic source for the submitted Click Dimensions form. We have CD forms embedded in iframes on our WP page and I’d like to monitor on which url the form was submitted.

    1. Hi Tomasz, are you embedding the same form on multiple different pages? If so, then I don’t know how you could pass through the URL that the form is embedded in. There might be a way with development, but not something I would know how to do.

  3. I’ve tried to add the Dynamics 365 Marketing JavaScript snippet to Google Tag Manager but I’m not seeing any web traffic. Any tips on how to get this to work?

    1. Hi Nathan, sorry for the delay, hopefully, you have it working now? If not, and you are sure you have added your snippet in GTM correctly, I would suggest you contact Microsoft support. I have seen it before where the tracking hasn’t worked right away and they have needed to do something on their end.

Comments are closed for this post.