BlogSome is a free WordPress based web hosting service, which has been a popular choice before arrival of WordPress.com for bloggers who want a WordPress blogging platform without forking out a dime. Even BlogSome still uses the legacy WordPress version 1.5.1-alpha, it still attract some bloggers as it allows blogger to add and place own ads such as Google AdSense on the blog.

BlogSome has been using Smarty template engine as its presentation framework. As a result, when user adds Google Analytics tracking code by placing either new tracking code (ga.js) or legacy tracking code (urchin.js) in BlogSome HTM source code (accessible via Manager -> Files), the following error occurs when any web pages on the blog is opened or visited.

Smarty syntax error

File index.html, line 280: syntax error:
unrecognized tag ‘var’

If you own this blog, and wish to fix this problem, you can log in here.

Google Analytics Tracking Code BlogSome Error

The error happens because Smarty template engine attempts to translate and interpret some keywords in Google Analytics tracking code that conflict with Smarty template delimiter syntax. As a workaround, Smarty does provide tags, {literal} and {/literal}, which allows a block of data to be taken literally.

{literal} tags are typically used around Javascript or stylesheet blocks where {curly braces} would interfere with the template delimiter syntax. Anything within {literal}{/literal} tags is not interpreted, but displayed as-is. It means anything inside the tags will be appeared exactly the same in the final HTML output for web browser to interpret, and no change will be done by Smarty engine.

Thus, to fix Google Analytics tracking code error on BlogSome, just embed the tracking code with {literal} before Google Analytics Javascript code, succeeding with {/literal} after the tracking. For example,

{literal}
Google Analytics Tracking Code Append Here
{/literal}

Related Posts