Forum Moderators: open

Message Too Old, No Replies

Problem rendering Google Analytics code

         

knkk

11:48 am on Dec 29, 2008 (gmt 0)

10+ Year Member



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-#*$!#*$!-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!

tkien

2:39 pm on Dec 29, 2008 (gmt 0)

10+ Year Member



you can copy the google code to external js called 'script.js' and upload it to your server. Then place code to your site

<script src="http://www.yoursite.com/script.js" type="text/javascript">

hope it works

knkk

4:25 am on Dec 30, 2008 (gmt 0)

10+ Year Member



Thanks a lot, tkien!