1 (edited by Kato 2006-06-21 18:43)

Topic: Google Analytics and PunBB

I'm sure many of you are familiar with Google Analytics.  I use this service on some of my sites and I really like the way it displays and tracks users and allows you to set goals.

Has anyone tried or maybe found a way (a plugin I think would be easiest, but I'm not a coding guru) to make a simple way to add in the Google tracking to your punbb site?  I use Drupal on a few sites and they have a simple mod that allows you to just enter your Analytic ID and it inserts it on all the pages for you. 

Can something like this be done for PunBB?

Just seems like a convenient thing to do with the miniportals and what not that allow you to in essence, create a website straight out of punbb.

Edit #2:  Would you be able to add their script that they give you to one of the tpl pages or something like that?

Re: Google Analytics and PunBB

Add it to main.tpl

http://fluxbb.org

Free PunBB Hosting - lots of mods, easy to customize

3

Re: Google Analytics and PunBB

Smartys wrote:

Add it to main.tpl

I was wondering if there wasn't an easy place to add it in.  I can put it in there and it will be used on all pages for the forums, right?

Re: Google Analytics and PunBB

yes. i did the same thing but with mint and i got back a mountain of stats.

~James
FluxBB - Less is more

5

Re: Google Analytics and PunBB

Dr.Jeckyl wrote:

yes. i did the same thing but with mint and i got back a mountain of stats.

Do you still use it?  PunBB is very fast and occasionally I see this little google script slow my other sites down...does that happen with you?

6

Re: Google Analytics and PunBB

Kato, I've wondered the same thing.

I know when I put Google Ads on my sites, they slowed down a bit so I've held off on Analytics.

7

Re: Google Analytics and PunBB

I can tell you from experience on my other sites that you do sometimes get a little longer load time. If you spend a lot of time on your site (which I do...it's my site, right?) you will sometimes see the screen pausing for a second. In your status bar, it says it is contacting google-analytics. It pauses for about 2 full seconds and then the page loads as quick as normal. I have seen this on 3 different sites that I run and all 3 use Google Analytics. I wasn't sure though if it may have been something with Drupal. I used it on those three sites (I kinda like Drupal, easy to work with).

Now though, I just put the script in my PunBB site and I was just surfing my site and I just experienced the exact same thing. So I know it has nothing to do with Drupal, it's Google Analytics.  I love Google Analytics, but I may pull the code out due to the occasional slow page load.

8

Re: Google Analytics and PunBB

Then I won't bother with it then, Awstats gives me enough info.

9

Re: Google Analytics and PunBB

Do you put the Google Analytics HTML code into your <head> or <body>...

I had the in <head>, and they still are there for my main site, but I've put it just before </body></html> 'cause thats what it says on the Google Analytics home page, when they give you the code. Funny, it probably wasn't there the first time I was getting my code.

http://www.info-mob.com/forum/ - Croatian forum only, don't bother if you don't speak Croatian :)

10

Re: Google Analytics and PunBB

You know...you are right.  I wonder if that will make a difference or not.  I remember when I first signed up that it instructed you to put it in the <head>  I think I'll move to the end of the <body> and see if that makes any difference or not.

11 (edited by mat 2006-06-22 06:16)

Re: Google Analytics and PunBB

I edited header.php, and put the code after line 70 like this:

?>

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "**-******-*";
urchinTracker();
</script>

<?php

replace your _uacct  with your own.

Re: Google Analytics and PunBB

Kato wrote:
Dr.Jeckyl wrote:

yes. i did the same thing but with mint and i got back a mountain of stats.

Do you still use it?  PunBB is very fast and occasionally I see this little google script slow my other sites down...does that happen with you?

it was a very slight slowdown but nothing i worried about.

~James
FluxBB - Less is more

Re: Google Analytics and PunBB

Kato wrote:

You know...you are right.  I wonder if that will make a difference or not.  I remember when I first signed up that it instructed you to put it in the <head>  I think I'll move to the end of the <body> and see if that makes any difference or not.

Google actually recommends that you put it at the end of your document: http://www.google.com/support/analytics … swer=26908

Copy and paste the code segment into the bottom of your content, immediately before the </body> tag of each page you are planning to track.

14

Re: Google Analytics and PunBB

The reason why they recommend this is because everything located inside <head></head> (sripts, css files, etc.) should be loaded before the page...

http://www.info-mob.com/forum/ - Croatian forum only, don't bother if you don't speak Croatian :)

15

Re: Google Analytics and PunBB

i put mine in main.tpl just before </body> but i'm not having any luck with Google Analytics seeing it, it works on my other sites... not sure...

16

Re: Google Analytics and PunBB

no one? :-/

17

Re: Google Analytics and PunBB

solace wrote:

no one? :-/

i did the same today, we will see how it works. i think is ok, because is after everything loads

18 (edited by NetworkShadow 2008-08-01 10:27)

Re: Google Analytics and PunBB

solace wrote:

i put mine in main.tpl just before </body> but i'm not having any luck with Google Analytics seeing it, it works on my other sites... not sure...

I'm using 1.3 RC. I did the same, and mine also can't see that the code is installed but it's getting stats back... Really strange.

Has anyone tried tracking usernames with the "User Defined" report?

<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">
var pageTracker = _gat._getTracker("account#No");
pageTracker._initData();
pageTracker._trackPageview();
pageTracker._setVar("<?php
echo $forum_user['username'];
?>");
</script>

This part of the code should track what users are logged-in:

pageTracker._setVar("<?php
echo $forum_user['username'];
?>");

I'm not sure if I've got that code right because it seems to break the stats tracking code altogether. Any suggestions?

UPDATE: Ok I figured-out that you can't really use php in the template main.tpl. I managed to get the above code working by putting it in the footer.php It's ugly, but it works... I hope there's an extension soon to allow custom tracking code.

19

Re: Google Analytics and PunBB

Did anyone find an extension for analytics?

20

Re: Google Analytics and PunBB

Have you tried this extension by Garciat?

21

Re: Google Analytics and PunBB

Just installed it now, thank you!