I have a webstore, running ASPDOTNETSTOREFRONT.
I'm trying to add a custom line of tracking script to a set of webpages.
To do this, i'm adding a Google Tag Manager script to the XML package that these pages use, so it appears on all the pages I want to track.
I've simply copied and pasted the Google Tag Manager script into my XML package.
`<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-5HD6WH"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<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=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-5HD6WH');</script>
<!-- End Google Tag Manager -->`
But when I try to load a page using this package, it gives the following error.
Exception=Error in XmlPackage(.Load), Package=[product.engineproduct.xml.config], Msg=[Exception=An error occurred while parsing EntityName. Line 246, position 42.
]
So people can see the line numbers and position, I can show a screenshot from the XML package (source code).
https://i.sstatic.net/mJ2Tb.jpg
Anyone have any suggestions how to fix this?
Try putting the script contents in CDATA:
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-5HD6WH"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>
<![CDATA[
(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=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-5HD6WH');
]]>
</script>
<!-- End Google Tag Manager -->