I am using Joomla and trying to incorporate Google Website Optimizer code within content to test site images and text content. Below is the Control Script (note the Bolded Section):

<script>
function utmx_section(){}function utmx(){}
(function(){var k='0241650748',d=document,l=d.location,c=d.cookie;function f(n){
if(c){var i=c.indexOf(n+'=');if(i>-1){var j=c.indexOf(';',i);return c.substring(i+n.
length+1,j<0?c.length:j)}}}var x=f('__utmx'),xx=f('__utmxx'),h=l.hash;
d.write('<sc'+'ript src="'+
'http'+(l.protocol=='https:'?'s://ssl':'://www')+'.google-analytics.com'
[B][B]+'/siteopt.js?v=1&utmxkey='+k+'&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='
+new Date().valueOf()+(h?'&utmxhash='[/B][/B]+escape(h.substr(1)):'')+
'" type="text/javascript" charset="utf-8"></sc'+'ript>')})();
</script>

When I view source on the page with this script included, I get the following:

<script>
function utmx_section(){}function utmx(){}
(function(){var k='0241650748',d=document,l=d.location,c=d.cookie;function f(n){
if(c){var i=c.indexOf(n+'=');if(i>-1){var j=c.indexOf(';',i);return c.substring(i+n.
length+1,j<0?c.length:j)}}}var x=f('__utmx'),xx=f('__utmxx'),h=l.hash;
d.write('<sc'+'ript src="'+
'http'+(l.protocol=='https:'?'s://ssl':'://www')+'.google-analytics.com'
[B][I]+'/siteopt.js?v=1&amp;utmxkey='+k+'&amp;utmx='+(x?x:'')+'&amp;utmxx='+(xx?xx:'')+'&amp;utmxtime='
+new Date().valueOf()+(h?'&amp;utmxhash[/I][/B]='+escape(h.substr(1)):'')+
'" type="text/javascript" charset="utf-8"></sc'+'ript>')})();
</script>

In HTML, the content of <script> elements is supposed to be CDATA, but in this case it is not being rendered as such. One potential solution would be to include the script in a separate php file and include it from the content page <script src="…">.... Im going to try that now. ...

Followup: I tried to include the following in my content: <script type="text/javascript" src="/js/googlecontrolscript.js"></script> BUT that was all that was rendered in the output so this didn't work.

Any other ideas on how to present the '&' directly and not have it translate into &amp;?

Thanks,
Nick

try changing the outermost script tags to

<script type='text/javascript'>
<!--
<![CDATA[
]]>
-->
</script>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.