Problems with Ampersands and Google Website Optimizer in Joomla CMS

Reply

Join Date: Jun 2009
Posts: 1
Reputation: nthomas is an unknown quantity at this point 
Solved Threads: 0
nthomas nthomas is offline Offline
Newbie Poster

Problems with Ampersands and Google Website Optimizer in Joomla CMS

 
0
  #1
Jun 11th, 2009
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'
+'/siteopt.js?v=1&utmxkey='+k+'&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='
+new Date().valueOf()+(h?'&utmxhash='+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'
+'/siteopt.js?v=1&amp;utmxkey='+k+'&amp;utmx='+(x?x:'')+'&amp;utmxx='+(xx?xx:'')+'&amp;utmxtime='
+new Date().valueOf()+(h?'&amp;utmxhash='+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
Last edited by Tekmaven; Jun 11th, 2009 at 11:04 pm. Reason: Code Tags
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,358
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 163
almostbob's Avatar
almostbob almostbob is online now Online
Nearly a Posting Virtuoso

Re: Problems with Ampersands and Google Website Optimizer in Joomla CMS

 
0
  #2
Jun 11th, 2009
try changing the outermost script tags to
  1. <script type='text/javascript'>
  2. <!--
  3. <![CDATA[

  1. ]]>
  2. -->
  3. </script>
Last edited by almostbob; Jun 11th, 2009 at 9:37 pm.
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC