Web Hosting - Find jobs - Wordpress Themes - Debt Consolidation - Wordpress Themes

PDA

View Full Version : Problem rendering Google Analytics code


knkk
Dec 29th 2008, 3:48 am
I am trying to include this code in the footer.template files of all blog templates:

<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{
var pageTracker = _gat._getTracker("UA-xxxxxx-x");
pageTracker._trackPageview();
} catch(err) {}</script>

However, the actual blogs are rendering it like this:

<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 catch(err) </script>

with this error also displayed:

Exception message: Smarty error: [in ./templates//FallingLeaves/footer.template line 16]: syntax error: unrecognized tag 'var' (Smarty_Compiler.class.php, line 590)
Error code: 256
-- Backtrace --
/home/blogs/class/template/smarty/Smarty.class.php(1095): trigger_error
/home/blogs/class/template/smarty/Smarty.class.php(1817): smarty_compiler.trigger_error
/home/blogs/class/template/smarty/Smarty_Compiler.class.php(2218): smarty_compiler._trigger_fatal_error
/home/blogs/class/template/smarty/Smarty_Compiler.class.php(590): smarty_compiler._syntax_error
/home/blogs/class/template/smarty/Smarty_Compiler.class.php(312): smarty_compiler._compile_tag
/home/blogs/class/template/smarty/Smarty.class.php(1491): smarty_compiler._compile_file
/home/blogs/class/template/smarty/Smarty.class.php(1424): cachedtemplate._compile_source
/home/blogs/class/template/smarty/Smarty.class.php(1869): cachedtemplate._compile_resource
/home/blogs/class/template/template.class.php(145): smarty._smarty_include
/home/blogs/tmp/583/%%8B^8B4^8B48D04F%%postandcomments.template.php(192): cachedtemplate._smarty_include
/home/blogs/class/template/smarty/Smarty.class.php(1265): include
/home/blogs/class/template/cachedtemplate.class.php(43): smarty.fetch
/home/blogs/class/view/smartyview.class.php(257): cachedtemplate.fetch
/home/blogs/class/view/blogview.class.php(286): smartyview.render
/home/blogs/class/view/viewarticleview.class.php(88): blogview.render
/home/blogs/class/controller/controller.class.php(399): viewarticleview.render
/home/blogs/showblog.php(51): blogcontroller.process

Exception message: Smarty error: [in ./templates//FallingLeaves/footer.template line 17]: syntax error: unrecognized tag: (Smarty_Compiler.class.php, line 446)
Error code: 256
-- Backtrace --
/home/blogs/class/template/smarty/Smarty.class.php(1095): trigger_error
/home/blogs/class/template/smarty/Smarty.class.php(1817): smarty_compiler.trigger_error
/home/blogs/class/template/smarty/Smarty_Compiler.class.php(2218): smarty_compiler._trigger_fatal_error
/home/blogs/class/template/smarty/Smarty_Compiler.class.php(446): smarty_compiler._syntax_error
/home/blogs/class/template/smarty/Smarty_Compiler.class.php(312): smarty_compiler._compile_tag
/home/blogs/class/template/smarty/Smarty.class.php(1491): smarty_compiler._compile_file
/home/blogs/class/template/smarty/Smarty.class.php(1424): cachedtemplate._compile_source
/home/blogs/class/template/smarty/Smarty.class.php(1869): cachedtemplate._compile_resource
/home/blogs/class/template/template.class.php(145): smarty._smarty_include
/home/blogs/tmp/583/%%8B^8B4^8B48D04F%%postandcomments.template.php(192): cachedtemplate._smarty_include
/home/blogs/class/template/smarty/Smarty.class.php(1265): include
/home/blogs/class/template/cachedtemplate.class.php(43): smarty.fetch
/home/blogs/class/view/smartyview.class.php(257): cachedtemplate.fetch
/home/blogs/class/view/blogview.class.php(286): smartyview.render
/home/blogs/class/view/viewarticleview.class.php(88): blogview.render
/home/blogs/class/controller/controller.class.php(399): viewarticleview.render
/home/blogs/showblog.php(51): blogcontroller.process

Exception message: Smarty error: [in ./templates//FallingLeaves/footer.template line 17]: syntax error: unrecognized tag '' (Smarty_Compiler.class.php, line 590)
Error code: 256
-- Backtrace --
/home/blogs/class/template/smarty/Smarty.class.php(1095): trigger_error
/home/blogs/class/template/smarty/Smarty.class.php(1817): smarty_compiler.trigger_error
/home/blogs/class/template/smarty/Smarty_Compiler.class.php(2218): smarty_compiler._trigger_fatal_error
/home/blogs/class/template/smarty/Smarty_Compiler.class.php(590): smarty_compiler._syntax_error
/home/blogs/class/template/smarty/Smarty_Compiler.class.php(312): smarty_compiler._compile_tag
/home/blogs/class/template/smarty/Smarty.class.php(1491): smarty_compiler._compile_file
/home/blogs/class/template/smarty/Smarty.class.php(1424): cachedtemplate._compile_source
/home/blogs/class/template/smarty/Smarty.class.php(1869): cachedtemplate._compile_resource
/home/blogs/class/template/template.class.php(145): smarty._smarty_include
/home/blogs/tmp/583/%%8B^8B4^8B48D04F%%postandcomments.template.php(192): cachedtemplate._smarty_include
/home/blogs/class/template/smarty/Smarty.class.php(1265): include
/home/blogs/class/template/cachedtemplate.class.php(43): smarty.fetch
/home/blogs/class/view/smartyview.class.php(257): cachedtemplate.fetch
/home/blogs/class/view/blogview.class.php(286): smartyview.render
/home/blogs/class/view/viewarticleview.class.php(88): blogview.render
/home/blogs/class/controller/controller.class.php(399): viewarticleview.render
/home/blogs/showblog.php(51): blogcontroller.process

I'd be quite grateful for any help!

dimitar christoff
Jan 1st 2009, 11:39 am
i think smarty does not like seeing braces { } as they indicate the start of control structure or a variables. to escape them, try:

{ldelim} instead of { and {rdelim} instead of }.

knkk
Jan 1st 2009, 8:21 pm
Thanks! I put {literal} and {/literal} instead, and they worked too.

amasum
Mar 10th 2009, 7:47 am
Thanks! I put {literal} and {/literal} instead, and they worked too.

finally found the solution I was looking for..thanks..