In June 2020, I put together a 30-day series that covered Google Analytics. Since then, I have had several questions about how you can add it to a Dynamics Portal, but using Google Tag Manager. So a quick blog and video hopefully will help! Here are the main points, but the video walks through the entire thing, with creating your Google Analytics (GA) account, and then adding the Google Tag Manager (GTM) code to the portal. If you are not sure of the purpose of GTM or how to get started, check out this post for more information and how to add your GA tracking code to GTM. Once you have done this, continue with the next steps.
Now the GTM code needs to be added to your Dynamics Portal. This can be found from the Admin area then going to Install Google Tag Manager.
We can see here that the code provided is in two parts. The first should be added as high in the <head> tag as possible, while the second should be immediately after the opening <body> tag.
Speak with the person who set up and configured your portal to see which option is right for your implementation, but the code should be added to the header web template. This can be done using a Content Snippet and adding that to the template, but below I have added it directly to the source code of the file. At the very top of the file, paste the first set of code you have been given in GTM.
We don’t have direct access to find and get to the <body> tag, but pasting the second lot of code from GTM at the bottom of the header web template will work. Save the file once you have added both sets of code.
Once you have saved the file, go back to GTM and submit the changes. Then, click on the Preview option. This will put your site in to preview mode (only for you), which then allows you to go and visit the portal in a browser. If you already had the portal open in a tab, make sure you refresh it.
You should now see the Tag Manager panel at the bottom of the site. What you are looking for is to make sure the Google Analytics tag actually fired. This shows that you set up your GA variable and related tag correctly, and you have the GTM tracking code in the right place on your portal.
If you then open up Google Analytics, you should see that you have one visitor (that is you!) right now. That’s it! You can now use Google Analytics to review and analyse the traffic to your Dynamics Portal.
*This post is locked for comments