How to implement Google Analytics in your Simple Machines Forum

Simple Machines Forum is today’s trend in bulletin boards.

It’s almost the same implementation of wordpress, here’s the quick and dirty way of implementing your google analytics, woopra, sitemeter or whatever you use to check your Simple Machines Forum’s web statistics.

Step 1: Create an include file for your Google Code.

Paste the following code in an empty text file and save it in /smf/Sources as /smf/Sources/analytics.php (.html or .htm will do)

Replace UA-#######-# with your Web Property ID from your web analytics account.

Step 2: Find the  index.template.php

Find your theme directory. Typically it will be the theme folder beneath /smf/Themes.

Open the file /smf/Themes//index.template.php

Step 3: Insert on line of code before the closing tag
Open index.template.php in a text editor.

Search for with </body>
You will find the following lines of code:

echo ‘
<div id=”ajax_in_progress” style=”display: none;’, $context['browser']['is_ie'] && !$context['browser']['is_ie7'] ? ‘position: absolute;’ : ”, ‘”>’, $txt['ajax_in_progress'], ‘</div></body></html>’;

Break the last </div> like this:

</div>’;

require_once’analytics.php’;
echo ‘</body></html>’;

Save the file and you’re done.

Testing.

View source your site, check if there’s google analytics before </body>

Enjoy!

Popularity: 11% [?]

Leave a Reply

Anti-Spam Protection by WP-SpamFree