- 37
Our customer is trying to add a Google remarking script to their site via the HTML Widgets plugin. We tell them they can add scripts via the HTML Widget -> Tools -> Source Code <> option. They are using the body_end_html_tag_before zone.
This is the script Google gave them (google_conversion_id changed) ... Note the /* commented */ CDATA lines in the original:
<!-- Google Code for Remarketing Tag -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 9999999999;
var google_custom_params = window.google_tag_params;
var google_remarketing_only = true;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/9999999999/?value=0&guid=ON&script=0"/>
</div>
</noscript>
After saving, the /* commented */ portions get parsed (which breaks the script):
<!-- Google Code for Remarketing Tag -->
<p>
<script>// <![CDATA[
var google_conversion_id = 9999999999;
var google_custom_params = window.google_tag_params;
var google_remarketing_only = true;
// ]]></script>
<script src="//www.googleadservices.com/pagead/conversion.js">// <![CDATA[
// ]]></script>
</p>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/9999999999/?value=0&guid=ON&script=0"/>
</div>
</noscript>
See the following support URL from Google on the topic:
https://support.google.com/tagassistant/answer/2978937?ref_topic=2947092#cdata_comments
Id really like to avoid having to add this to any CSHTML files since a) this puts scripting back in our court as opposed to letting our customers maintain this info themselves, and b) this complicates upgrades.
FWIW we are seeing similar issues on other 3rd-party scripts as well. Any thoughts on how to handle this?
This is the script Google gave them (google_conversion_id changed) ... Note the /* commented */ CDATA lines in the original:
<!-- Google Code for Remarketing Tag -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 9999999999;
var google_custom_params = window.google_tag_params;
var google_remarketing_only = true;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/9999999999/?value=0&guid=ON&script=0"/>
</div>
</noscript>
After saving, the /* commented */ portions get parsed (which breaks the script):
<!-- Google Code for Remarketing Tag -->
<p>
<script>// <![CDATA[
var google_conversion_id = 9999999999;
var google_custom_params = window.google_tag_params;
var google_remarketing_only = true;
// ]]></script>
<script src="//www.googleadservices.com/pagead/conversion.js">// <![CDATA[
// ]]></script>
</p>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/9999999999/?value=0&guid=ON&script=0"/>
</div>
</noscript>
See the following support URL from Google on the topic:
https://support.google.com/tagassistant/answer/2978937?ref_topic=2947092#cdata_comments
Id really like to avoid having to add this to any CSHTML files since a) this puts scripting back in our court as opposed to letting our customers maintain this info themselves, and b) this complicates upgrades.
FWIW we are seeing similar issues on other 3rd-party scripts as well. Any thoughts on how to handle this?