How to Add Google Analytics Tracking Code in vBulletin 4
When adding or inserting Google Analytics tracking code in vBulletin 4 forums software, either in styles, templates, plugins, products or ad HTML code of newly added advertising function, error message similar to the following may appear when saving the code:
The following error occurred when attempting to evaluate this template:
Parse error: syntax error, unexpected ‘[‘
in /home/forums/includes/adminfunctions_template.php(4595) : eval()’d code on line 18This is likely caused by a malformed conditional statement. It’s highly recommended that you fix this error before continuing, but you may continue as-is if you wish.
Two options of “Go Back” or “Continue” are available for user selection. And of course, even if user forcefully save and make active or enable the Google Analytics tracking code, the script doesn’t work, and does not appear on web pages.
Google Analytics tracking code or script contains some special characters which does not parse properly. Thus, in order to embed Google Analytics tracking code, the easier way is to wrap the code with <vb:literal> and </vb:literal> tags so that the code is treated literally during page rendering.
For example,
<vb:literal>
<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("****");
pageTracker._trackPageview();
} catch(err) {}</script>
</vb:literal>
The Google Analytics tracking code can be placed in footer template, or better suggestion is to place it into ad_footer_end template (inside Ad Location Templates) as to avoid future upgrading issues where templates need to manually merged.
Related Articles
- Use {Literal} Smarty Tag to Add Google Analytics Tracking Code to BlogSome Hosted Blogs
- WordPress Plugin: Display Google Analytics and FeedBurner Reports Statistics from Site Admin
- Official Google Analytics Blog Offers Tips and Information
- Google Analytics for Mobile Server-Side Tracks Mobile Phone and PDA Devices
- How to Remove or Delete (Unlink) Google AdSense and Analytics Integration
- How to Disable and Turn Off vBulletin Plugin and Product System
- Remove and Disable Google Analytics Tags (?utm_source &utm_medium) in FeedBurner URL
- Hack to Add Forum Sponsors to vBulletin Categories and Forums
- Keep An Eye On Websites’ Performance Via BLVD Status Web Analytics Tool
- Remove and Strip Query String (Session ID or Question Mark) From URL with mod_rewrite (.htaccess)










































July 17th, 2010 01:48
Thanks. its working
April 20th, 2010 00:05
thank you. this is good tips for me.
March 18th, 2010 22:29
Thanks, very helpful
March 10th, 2010 00:59
Thanks for the help
February 8th, 2010 16:18
Thanks, it works for the forums.
February 7th, 2010 01:54
Same here, you saved the day!
January 27th, 2010 11:26
Thanks for the post, could not find the answer at vbulletin.org. Worked like charm.