Problem adding Google Analytics script to topic content

Topics: Developer Forum, User Forum
Feb 11, 2015 at 8:34 PM
Environment info: We're currently using v1.9.8.0 with the VS2010 Presentation style.

I'm trying to add a Google Analytics script to my Sandcastle site but am having some issues.

I've added the following script to the footer_content Resource Item, so that it will appear on all of my content pages (I've changed my tracking code below, but everything else is the same):

<script type='text/javascript'>(function(i,s,o,g,r,a,m){{i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){{(i[r].q=i[r].q||[]).push(arguments)}},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)}})(window,document,'script','//','ga');ga('create','XX-33333333-3', 'auto');ga('send', 'pageview');</script>

Per some advice I read on other posts here, I doubled up my curly braces and added the script as a single line.

When I build, the script contents are lost, and the only thing that shows up in the html output of my footer is:

<script type="text/javascript"><!----></script>

I tested out encoding my < and > characters with '%253C' and '%253E', but that didn't fix it.

Am I doing something wrong? Is there a better way to add a script to my html body content?
Feb 13, 2015 at 3:07 PM
As I recall this is a problem caused by the branding component transformations as they didn't check for and pass literal script through like they should. Those have been removed in the latest release so if you can upgrade to it, this shouldn't be an issue anymore. Also, please note that this project has moved to GitHub. Please go there to ask any other questions as I won't be monitoring this site as often. Thanks.