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 18

This 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.

7 Responses to “How to Add Google Analytics Tracking Code in vBulletin 4”

  1. buddy
    July 17th, 2010 01:48
    7

    Thanks. its working :)

  2. Classifieds
    April 20th, 2010 00:05
    6

    thank you. this is good tips for me.

  3. Svyatoslav
    March 18th, 2010 22:29
    5

    Thanks, very helpful

  4. Jeremy
    March 10th, 2010 00:59
    4

    Thanks for the help

  5. Find Reviews
    February 8th, 2010 16:18
    3

    Thanks, it works for the forums.

  6. Magnus
    February 7th, 2010 01:54
    2

    Same here, you saved the day!

  7. Josh
    January 27th, 2010 11:26
    1

    Thanks for the post, could not find the answer at vbulletin.org. Worked like charm.

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to My Digital Life Comments RSS feed to receive notification of latest comments posted.

New Articles

Incoming Search Terms for the Article

vbulletin google analytics - google analytics vbulletin 4 - vbulletin 4 google analytics - google analytics vbulletin - vbulletin analytics - vbulletin 4 analytics - add google analytics to vbulletin 4 - analytics vbulletin 4 - analytics vbulletin - google analytics for vbulletin 4 - forums vbulletin advertising - using google analytics with vBulletin - google analytics in vbulletin 4 - adding google analytics to vbulletin 4 - google analytics for vbulletin - How to add google analytics to vbulletin 4 - vbulletin 4 google analytics code - vbulletin google analytics code - where to put google analytics code in vbulletin - Analytics Code Installation + vbulletin - adding google analytics to vbulletin4 - Google Analytics Mobile tracking code - google analytics mobile tracking code vb - write vbulletin 4 product - google analysis vbulletin - vbulletin 4 meta tags - vbulletin adding analytics - vbulletin google analytics 4.0 footer - demo of how to add tracking code for google - thanks button vbulletin 4 - vbulletin 4 add google analytics - vbulletin google tracking code - add analytics vbulletin - vbulletin 4 google adsense size - google analytics vbulletin 4.0 - where to put google analytics code vbulletin - putting google analytics in vbulletin 4.0 - adding google analytics tracking code to vbulletin index page - vbulletin4 analytics - how to add google analytics to vbulletin - vbulletin 4 google adsense - add analytics to vbulletin - vbulletin google analytics meta tag - where to put google analytics code in vbulletin 4 - google analytics code vbulletin 4 - how to add google analytics code to a vb template - vbulletin tracking code google - vbulletin 4 how to advertising - add thanks button to vbulletin 4 - google analytics serbian sites -