Reputation: 1551
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?
Upvotes: 5
Views: 1860
Reputation: 550
And 1 year later... I had the same problem in DNN 7.4.2.
I had something like this in httpdocs/SiteAnalytics.config
<?xml version="1.0" encoding="utf-8" ?>
<AnalyticsEngineConfig>
<Engines>
<AnalyticsEngine>
<EngineType>DotNetNuke.Services.Analytics.GoogleAnalyticsEngine, DotNetNuke</EngineType>
<ElementId>Head</ElementId>
<InjectTop>False</InjectTop>
<ScriptTemplate>
<!-- Google Tag Manager -->
<script type="text/javascript">
(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','<Tracking ID>');
</script>
<!-- End Google Tag Manager -->
<!-- documented... we would like to disable it by now
<![CDATA[
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '[TRACKING_ID]']);
_gaq.push(['_trackPageview']);
[PAGE_URL]
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
]]>
-->
</ScriptTemplate>
</AnalyticsEngine>
</Engines>
</AnalyticsEngineConfig>
See, by know i am leaving this as a manual change (but, as i am seeing now I think it will be very easy to integrate new google tag manager with DNN functionality and menus).
The change @dubloons proposed doesn't work for me, so i did it like this:
<?xml version="1.0" encoding="utf-8" ?>
<AnalyticsEngineConfig>
<Engines>
<AnalyticsEngine>
<EngineType>DotNetNuke.Services.Analytics.GoogleAnalyticsEngine, DotNetNuke</EngineType>
<ElementId>Head</ElementId>
<InjectTop>False</InjectTop>
<ScriptTemplate>
<!-- Google Tag Manager -->
<![CDATA[
<script type="text/javascript">
(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','<Tracking ID>');
</script>
]]>
<!-- End Google Tag Manager -->
<!-- documented... we would like to disable it by now
<![CDATA[
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '[TRACKING_ID]']);
_gaq.push(['_trackPageview']);
[PAGE_URL]
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
]]>
-->
</ScriptTemplate>
</AnalyticsEngine>
</Engines>
</AnalyticsEngineConfig>
As you see, i sourrounded al script tag within CDATA, not just JS code. will be something like GTM-XXXXXX. As you can see Tracking ID is hardcoded by know, but thats another issue ;D.
Upvotes: 1
Reputation: 1140
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 -->
Upvotes: 3