Log in

View Full Version : google analytics + archive questions


David_R
02-14-2006, 02:47 PM
hi,

Where should i place the google analytics code as follows in:
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-*****-*";
urchinTracker();
</script>

1. Vbulletin Archive
2. vB Easy Archive - Search Engine Spiderable Hack from Xenon

thanks.

Reeve of shinra
02-14-2006, 03:05 PM
In the default vbulletin archive, add a new plugin using the archive header start and add in this:


?>

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

<?php


Not sure about the other one.

David_R
02-14-2006, 09:11 PM
did you meant to add a new plugin to this page:
admincp/plugin.php?do=add ??

what should i select under hook location, sorry for being lame i have not read complete information about vb yet :(

thanks for helping.

Reeve of shinra
02-14-2006, 09:28 PM
yep thats the place. The hook location should be called something like archive header start or something close to it. Im at work and wont be home for a few hours but let me know if you cant find it or have problems :)

David_R
02-21-2006, 06:35 PM
yep thats the place. The hook location should be called something like archive header start or something close to it. Im at work and wont be home for a few hours but let me know if you cant find it or have problems :)

THANKS man, i just added the same above the </body> tag under <div> elements.

styleforum
05-19-2007, 07:45 PM
Could someone explain this a little more step-by-step? I'm trying to figure out how to do this. Surprised more people aren't wondering the same thing.

Dismounted
05-20-2007, 04:38 AM
Plugins & Products > Add New Plugin > Hook Location: archive_header_start > Paste code as above.

firstrebel
05-20-2007, 06:47 AM
Does the code put into the footer template not work for the archive?

Bob

Dismounted
05-20-2007, 07:09 AM
It probably does, but I don't know why Reeve of shinra instructed to do it using plugins. I was assuming it wouldn't work the other way.

firstrebel
05-20-2007, 08:06 AM
I just looked at the page source in the Archive and the Google script was not there, so this suggests putting it in the footer template does not cover the archives.

I have not tried using it as a plugin yet and removing the code from the footer. Can anyone clear this up please?

Bob

Dismounted
05-20-2007, 09:53 AM
Ah, sorry about that, I though the Archive had it's own templates. No, it wouldn't work in the footer template as the archive generates its own HTML on-the-fly.

styleforum
05-20-2007, 05:08 PM
Yeah, I pulled the archive source after adding Google ads to the archive, and didn't see the tracker in there. So I tried editing the archive/index.php to include the script and it didn't work - wouldn't parse at all, I don't know what I'm doing in there exactly, just pasted it right before the </body>.

So does this plugin thing work for this purpose then? I'll try it. Thanks.

I must be blind, I don't see archive_header_start. I see:

archive_global
archive_process_start
archive_postheader
archive_navigation
archive_forum
archive_forum_thread
archive_thread_post
archive_complete

Dismounted
05-21-2007, 06:25 AM
Use archive_process_start :).

styleforum
05-21-2007, 06:52 AM
Thanks, I used archive_complete and it worked, so I think I'll leave it. Cheers.

Spinball
07-03-2007, 01:11 PM
I used archive_complete and get the following error:
Parse error: syntax error, unexpected '<' in /home/sites/avforums/public_html/forums/archive/index.php(453) : eval()'d code on line 1
when I view archive pages using 3.6.7PL1

Dismounted
07-04-2007, 05:18 AM
What are you putting in for the PHP code.

Spinball
07-04-2007, 07:19 AM
What are you putting in for the PHP code.

Erm, just putting the Google HTML Script tags. No PHP code.

Fixed it.
You have to put $output .= "<script src=\"http://www.google-analytics.com/urchin.js\" type=\"text/javascript\">
</script>
<script type=\"text/javascript\">
_uacct = \"XX-XXXXXXX-X\";
urchinTracker();
</script>"; in to the archive_complete hook.

Voyager-S
04-20-2008, 08:45 AM
I'm bumping this thread as I really want to have my archive tracked by Google Analytics, however the new code is different from the one you posted above. My new code looks 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">
var pageTracker = _gat._getTracker("UA-XXXXXXX-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>

What should I do to have this added to my archive? I tried using a plugin from archive_complete but I get a parse error everytime, and other different errors.

Anybody? thanks in advance :)

Dismounted
04-20-2008, 08:59 AM
$output .= '<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("UA-XXXXXXX-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>';

Voyager-S
04-20-2008, 09:12 AM
$output .= '<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("UA-XXXXXXX-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>';
Oh wow, thank you!! It finnally works. Now I only have to wait and see if the results get tracked in Google Analytics :)

Thanks again, dismounted!

adnoid
02-25-2009, 07:57 PM
Thanks for this thread - I just did this on our forum. The Google code has changed a little bit:

$output .= '<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-1");
pageTracker._trackPageview();
} catch(err) {}</script>
';

The key to getting it to work as a plugin is:

--Add this first:

$output .= '

--Paste your Google code

--Add this at the end:

';

--Go through the pasted Google code and anywhere there is a single quote (') escape it with a backslash (\'), LEAVING the first and last single quotes you added above. You can find 4 places in the code I put above, and there should always be an even number!