SHARE

google  analytics smfSMF (Simple Machine Forum) the simple yet discussion open source forum software. I have been using this software in one of my website from one year. I love SMF because of its simplicity and fast loading. Recently, I have added Google analytics in my SMF to track the visitors. The file structure of  SMF is easy to understand and is easy to put the analytics code as well.

If you are using SMF and confused on how to add Google Analytics tracking then this post will help you overcome your confusion. First of all navigate to the your theme folder, there you will see a file “index.template.php,” it is the core file that controls the theme. Open this file with your favorite text editor, for example, Notepad++. Then find in this file andpaste your trackingcode just before like this,

 echo ‘
</div>

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-xxxxxxx']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

</body></html>’;

The code above is for demonstration purpose only, you need to keep your own Google Analytics code. You can now confirm the code from page source and webmaster tool.

If you don’t want to mess up editing files then you can install SMF mod named Google Analytics code from here.