Forums / Setup & design / Google analytics code chopped
Erland Flaten
Wednesday 28 April 2010 2:23:45 am
How do I get Google Analytics to work?
I have pasted those two javascript codes in both “pagelayout.tpl” and in “page_footer_script.tpl”, but the javascript gets cut of after “try” which is just before the pagetracker code. This happens in both templates.
You can see it at fabrikken.org
Is it easier to get Analytics to work by using the BC website Statistc extension?
here is my page_footer_script.tpl
{if $pagedesign.data_map.footer_script.has_content}<script language="javascript" type="text/javascript"><!-- {$pagedesign.data_map.footer_script.content} --></script>{/if}{* Override this template and place javascript based statestics here (like Google Analytics) *} <script type="text/javascript">var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));</script><script type="text/javascript">try{<span> </span>var pageTracker = _gat._getTracker("UA-15751810-1");pageTracker._trackPageview();} catch(err) {}</script>{if $pagedesign.data_map.footer_script.has_content}<script language="javascript" type="text/javascript"><!-- {$pagedesign.data_map.footer_script.content} --></script>{/if}{* Override this template and place javascript based statestics here (like Google Analytics) *} <script type="text/javascript">var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));</script><script type="text/javascript">try{<span> </span>var pageTracker = _gat._getTracker("UA-15751810-1");pageTracker._trackPageview();} catch(err) {}</script>
Erland Flaten Lilllehammer, Norway
Nicolas Pastorino
Wednesday 28 April 2010 2:42:30 am
Hallo Erland,
You need to encapsulate the GA code with the
{literal}{* GA code here *}{/literal}
tags, one of the methods for embedding javascript code in Exponential templates. More on this here : http://share.ez.no/forums/install-configuration/problem-with-adding-google-analytics-code .
Cheers !
-- Nicolas Pastorino Director Community - eZ Member of the Community Project Board eZ Publish Community on twitter: http://twitter.com/ezcommunity t : http://twitter.com/jeanvoye G+ : http://plus.tl/jeanvoye
Wednesday 28 April 2010 2:51:02 am
Works now :) Thanks for the explanation of the literal tag.