Analytics on PHPBB

Hi Guys,

Does anyone know a fix around getting Google Analytics to work on a PHPBB 2 Forum?

I have tryed the //phpbb comments in the code that I have read elsewhere.

Look forward to hearing back from anyone with an answer.

Cheers.

My forum doesn’t get that much traffic, but I put Google’s code in the template’s footer file and AFAIK it’s been working OK

Thanks for the reply.

Sorry I should of mentioned the code is in the footer and appears to be there successfully appearing to the source code.

The sites analytics is working everywhere but the forum.

Have read many others have had problems with this aswell but I have not found the solution.

Is your forum in a sub-domain (http://forum.website.com) or a sub-folder (http://www.website.com/forum/)?

This is normally where things get tripped up.

If you can view the Google Analytics code on the forum pages HTML, then it should be working. Further problem solving will probably require you to provide the URL.

Thanks for the reply.

Forum is in a subfolder at www.footytrends.com/forum

As you can see in the source the code is at the bottom of the page.

<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-198322-8");
pageTracker._trackPageview();
} catch(err) {//phpBB fix}
</script>

The code works fine on the rest of the website.

Other than code validation issues (which I wouldn’t think would affect this normally) I can’t see which the GA code isn’t being triggered.

I’d suggest dropping a ticket in their Help Forum

If you solve it make sure you let us know :slight_smile:

If the template is XHTML and being served as XHTML the document.write won’t work.

That’s only if you need HTTPS, so it might work OK if you hack that to hard-code, if it doesn’t go against the Terms.

Have just read elsewhere to try the following

Remove “try {” and “} catch(err) {}” lines completely

Will let yous know if this has any effect.

Love to here any other options in the meantime.

Thanks to everyone so far for there advice.

Just an update incase anyone else ever stumbles across this thread with the same problem.

The above method has worked fine.

thankyou everyone for the advice.