How to install Piwik on Simple Machine Forums

 

A while back I was having some problems installing Piwik on Simple Machine Forums (SMF), but I found a cool way how to add the code in any SMF installation.

For those who are unfamiliar with Piwik, here’s a small description:

Piwik is a downloadable, open source (GPL licensed) web analytics software program. It provides you with detailed reports on your website visitors: the search engines and keywords they used, the language they speak, your popular pages… and so much more.
 
 
 
 

 

I hope this small tutorial will be very useful to you on installing Piwik on Simple Machine Forums (SMF).

Just follow this steps:

  • Create an HTML file, called e.g. piwik.html
  • Go to your Piwik installation, get the code and copy it into your newly created HTML file (the code is similar to what you see below, but please do generate your own, the code below might be outdated)
     
    <a href="http://piwik.org" title="Web analytics" onclick="window.open(this.href);return(false);">
    
    <script type="text/javascript">
    
    var pkBaseURL = (("https:" == document.location.protocol) ? "https://SUBDOMAIN.DOMAIN.com/" : "http://SUBDOMAIN.DOMAIN.com/");
    
    document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
    
    </script>
    
    <script type="text/javascript">
    
    <!--
    
    piwik_action_name = '';
    
    piwik_idsite = 1;
    
    piwik_url = pkBaseURL + "piwik.php";
    
    piwik_log(piwik_action_name, piwik_idsite, piwik_url);
    
    //-->
    
    </script><object>
    
    <noscript>
    
    Web analytics <img src="http://SUBDOMAIN.DOMAIN.com/piwik.php" style="border:0" alt="piwik"/>
    
    </noscript></object></a>
     
  • Upload this into Sources, you can find this folder in the root of your installation. If you installed your website in a folder called “forum”, this folder will be at forum/Sources.
  • Now go into the theme folder that you are using, and open the file index.template.php. If you installed your website in a folder called “forum”, the exact location of this file would then be forum/Themes/your-theme/index.template.php.
  • Search for:
  •  
    echo '
    
    </body>
    
    </html>';

    Replace with:

    // Add in Piwik
    require_once 'piwik.html';
    
    echo '
    
    </body>
    
    </html>';
  • Close and upload!

If you look into the source of your webpage (any webpage) of your website, you will be seeing your Piwik analytics code.

Comments are closed.

Trackback URI |