Nov 05.
2009

This is a guide on how to installing Google Analytics to phpBB.

First of all, you need phpBB3 forum and Google Analytics -account.

1. Get Google Analytics code.
It should look like this
<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("UA-xxxxxxx-x");
pageTracker._trackPageview();
} catch(err) {}</script>

2. Copy-Paste it to Notepad or some program like that.

3. Add “//phpbb fix” inside {} at the last line.
Like this…
<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("UA-xxxxxxx-x");
pageTracker._trackPageview();
} catch(err) {//phpBB fix}</script>

4. Insert the modified code into overall_footer.html file, just before </body>, near the end of the document. Repeat for all active templates.

5. Upload the modified files to the server.

6. Refress all active templates, from the Admin Control Panel.

7. You’re done!

At the 3. step I have added a fix for known bug, within integration of phpBB 3.0.4 (and newer) and Google Analytics. The bug results blank stats for some users in Google Analytics, eventhough GA finds the code and says “receiving data”. Discussion about the bug at phpBB support forum.

The fix doesn’t alter the functionality in any way, so every1 can use it, just to be sure the stats work.

1 comment so far

Add Your Comment
  1. Finally a working solution! Thank you!

Lunarpages.com Web Hosting