I have GTM installed on my site. We already have canonical URLs on all of our pages, but Google Analytics is not tracking the canonical URLs, so the analytics are getting duplicate pages where the capitalization or querystrings are different. I've found answers on how to modify the Google Analytics snippet to track canonical URLs, such as this answer here, but the issue is that because I have GTM installed my code doesn't have the Google Analytics snippet. Instead, we have a GTM snippet:
<!-- Google Tag Manager -->
<script>(function (w, d, s, l, i) {
w[l] = w[l] || []; w[l].push({
'gtm.start':
new Date().getTime(), event: 'gtm.js'
}); var f = d.getElementsByTagName(s)[0],
j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src =
'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', <asp:Literal runat="server" id="gtmTag" />);</script>
<!-- End Google Tag Manager -->
How do I make Google Analytics use the canonical URL when I'm using GTM?