If you are using D365 Marketing, and are trying to make the most from all the functionality, you’ve likely set up a marketing website record and generated tracking code to add to your organisations corporate website. This means you can track visits to the site, most of which will be anonymous, but with named visits showing when a Contact in D365 interacts with the site (assuming they have cookies in their browser allowing this). However, if you’ve set up the tracking code using Google Tag Manager (which is good best practice), you might have noticed something strange this in your visits. This is where a series of visits show up with a url relating to Google Tag Manager (https://gtm-msr.appspot.com/render2?id=GTM-PLUS-YOUR-ID). What causes them and how do you get rid of them by filtering out Google Tag Manager Traffic? Read on for details.

If you don’t use Google Tag Manager you can probably just ignore all of this. If you are, you’ve likely set up a Custom HTML type tag and added your tracking code from D365 Marketing. Have a search through your website visits to see if you have anything like this. The Page address and Referrer URL both point to a link that includes your GTM id at the end of it. After doing some Googling, it came up that this could be caused by a couple of things. First, if someone is testing some GTM changes and previews them, but more likely it’s from visitors to your website who have JavaScript disabled in their browser. Google Tag Manager provides two scripts, one for those WITH JS enabled, and a no-script one that fires when JS is not enabled. This is fine and expected behaviour, but D365 Marketing still captures it as a visit. This isn’t unique to D365 and occurs in many other tracking utilities.

Click to view in detail

Thanks to this video I found here from Measure School, it explains perfectly how and why it happens. Their example was based on tracking when using Facebook Pixel, so I applied the same logic here. First thing, you have the tracking code for your website when you create the marketing website in D365.

Click to view in detail

Then in Google Tag Manager you likely created a tag with the Custom HTML type that fires on all pages of your website. Great!

Click to view in detail

However, what we are now going to do is split that up and create two tags that fire on all pages, both using the tag type of Custom HTML. In the first one we are going to add the items that are wrapped in the DIV tags. So the first line, then the last lines is what you need. You can see what you need below, but you will have a different div id, data-website-id and data-hostname. Make sure you use YOUR correct lines of the tracking code.

<div id="dWftIH4jZfZKXBmyVMsXR-9Zc60sbXrqbOBIVAeM9Fzo"></div>
<div class="d365-mkt-config" style="display:none" data-website-id="WftIH4jZfZKXBmyVMsXR-9Zc60sbXrqbOBIVAeM9Fzo" data-hostname="b3db011fec024820bd80f2114e60fabd.svc.dynamics.com"></div>

Add it in to a Custom HTML tag like this.

Click to view in detail

Now look at the Advanced Settings. We want to make sure the tag fires with a higher priority than the next tag we create, and also that it fires once per page. I set my priority to 2 but it just needs to have a higher number than your other tag firing priorities. The higher the number the higher the priority.

Click to view in detail

Now we need to add in some logic that would only fire the D365 Marketing script part when needed. The logic states, if the page visited includes appspot.com (which is part of that URL that is showing up in our website visits that we don’t actually want captured), DO NOT RUN THE SCRIPT, which means that visit will not be captured in D365 Marketing. If it doesn’t include that, then run the script and we will capture the visit as intended. I believe the script URL should be the same for all, BUT double check the link that you see in your Javascript code in D365 Marketing to be sure.

<script type="text/javascript">
if (document.location.href.search('appspot.com') == -1) {
	var script = document.createElement('script');
	script.src = 'https://mktdplp102cdn.azureedge.net/public/latest/js/ws-tracking.js?v=1.84.2007';
	var ref = document.querySelector('script');
	ref.parentNode.insertBefore(script, ref);

You should then be able to copy and paste this in to a new Custom HTML tag. Massive massive thank you to my brother, Owen Rumney, for the assist (AKA writing it) with the script logic.

Click to view in detail

Now go in to the Advanced Settings for this tag. I might be able to get away without using the priority again, but this time I set it as 1 so it’s a lower priority than the first tag with the DIVS. However, what I did make sure is that it fires once per page, and also that the D365 Marketing DIVS tag fires before this one and doesn’t fire is that tag fails or is paused. If we don’t make sure they are in this order and the script runs, the web page visit doesn’t know which D365 environment to link it back to, so you can end up with missing website visits.

Click to view in detail

This won’t remove any of the previous GTM visits you’ve captured, but it should stop them moving forwards. Again, as we’ve only done this in GTM for the D365 Marketing tracking code, it also shouldn’t impact anything else you have set up from a tag or trigger perspective. Hope this helps!

Check out the latest post:
Predefined Placeholder Access In Customer Insights - Journeys

D365 Marketing Weekly
Have you seen the D365 Marketing Weekly newsletter yet?
A weekly issue covering features, functionality and news on the topic of Marketing, specifically covering Dynamics 365 Marketing and other interesting tools and tips for anyone interested in the subject.
Subscribe Here
This is just 1 of 456 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.

4 thoughts on “Filtering Out Google Tag Manager Traffic From D365 Marketing Website Visits

  1. Hi Megan,

    So problem only occurs with visitors who do not have JS enabled? Is it even possible to browse the web with JS disabled? It feels like not, most website are rendered in the front end.

    Curious how other tools deal with this issue. I guess they could built it in the ignore?

    Fix would also be not to place the GTM iframe code in the page right?

    1. Hi Marten, there may well be other fixes sure, however Google Tag Manager gives you two scripts. One part goes in the head tag, the other one after the opening body tag (no script).

      I’ve seen those who specialise in analytics and GTM say that although removing the no script portion would resolve issues like this, it’s not recommended because it’s needed for other things like Google Analytics.

      It is 100% possible to browse the web with JS disabled. You can turn it off, or an organisation can set up policies to keep it turned off. Someone might also browse on a phone that doesn’t have it enabled. Finally, you have bots without Javascript enabled so this approach would also take care of those visits from a D365 Marketing perspective. Hope that helps!

  2. Hi Megan,
    I’m playing with the website tracking code snippet.
    It looks like the only way to resolve activity to an actual Contact record is to complete an Outbound Marketing Landing Page. I tried testing the submission of a Real-Time Marketing Form, and the website visit data did not get resolved to the contact.
    Do you have any informtion you can share on tracking website activity when you’re using RTM instead of OBM?

    1. Hi Michelle, annoyingly at the moment, what you found is accurate, and only OBM related traffic is captured in terms of form submissions. However, if you have the website tracking code, you should still see someone visited a page where any RTM forms are embedded. I am keeping my fingers crossed this will be added and included soon!!!

Leave a Reply

Your email address will not be published. Required fields are marked *