scriptygoddess

13 May, 2002

List Google Only Referrers

Posted by: Jennifer In: How to's

This will let you list your 50 most referrers from google hits.

First, download the LittleGreenFootballs referrer script.

Make duplicates of all the files adding this to the filename "-google"
example:
change lgf-reflog.php to lgf-reflog-google.php
change reflog.txt to reflog-google.txt
chagne semaphore.ref to semaphore-google.ref
etc.

Open the lgf-reflog-google.php file.
change this line:
$reflog = 'reflog.txt';
to
$reflog = 'reflog-google.txt';

change this line:
$semaphore = 'semaphore.ref';
to
$semaphore = 'semaphore-google.ref';

change this line:
$mydomain = 'mydomain.com';
to
$google = 'google.com';

change this line:
if (($ref) and (!strstr($ref, $mydomain))) {
to
if (($ref) and (strstr($ref, $google))) {

Open the show-refs-google.php file.
change this line:
$reflog = "reflog.txt";
to
$reflog = "reflog-google.txt";

Then make sure this line is at the top of all your pages (above the <html> tag) and that your page either has a PHP extension or make sure your site processes html files as php:
<?php
include('/HOME/PATH-TO-YOUR-FILES/lgf-reflog-google.php');
?>

the link to see your google hits:
http://www.YOURDOMAIN.COM/PATH-TO-YOUR-FILES/show-refs-google.php

Here's it working on this site:
Show Google Referrers

Update: With some major hacking – I grabbed the code from this script and mixed it in so that ONLY the search terms would show. I'm a little hesitant to publish here what I did because I don't want to violate any open source rules…

15 Responses to "List Google Only Referrers"

1 | Karla

May 13th, 2002 at 11:27 pm

Avatar

Is there any way you could modify the script to log everything BUT google hits? I get a lot of hits from google because of my domain name, and I'd much rather filter them all out so that I could just see hits from people actually linking to me.

2 | wKen

May 14th, 2002 at 2:19 am

Avatar

Thanks goddesses! And especially thanks to Christine for hearing my prayers. Now if I can just follow directions.

3 | wKen

May 14th, 2002 at 3:17 am

Avatar

I followed the directions (I think), and when I try to look at the last google referrers, I get this:

show-refs-google.phpÓ·„f ·„f mBIN‚?uy´

I'm not certain about my html file being processed as PHP (I'm not PHP literate), but other than that I was very careful. Do you have any suggestions?

4 | Row

May 14th, 2002 at 3:51 am

Avatar

Interesting :) Makes me almost want to remove all my nocache thingos in my meta tags.

5 | miss kathryn

May 14th, 2002 at 4:34 am

Avatar

pretty cool! it took a bit as i was being silly but it worked in the end :)

6 | Jennifer

May 14th, 2002 at 6:38 am

Avatar

wKen – can you send me the links to the page where you have that tracker (the page that has the include line) and the show-refs url?

also – lets do an experiment to test your PHP set up:
Create a file, name it testingPHP.php

Put the following in that file
<? phpinfo(); ?>

Upload to your server and open the page in your browser.

It should show a bunch of PHP information.

If that works, try this.

Change the extension of that file to .html

try loading it again.

If that works, let me know.

If if DOESN"T work, that means that your html pages aren't processing like PHP pages.

Here's how you get html pages to process like they're php pages

7 | Lynda

May 14th, 2002 at 7:05 am

Avatar

You might be able to explode those results (the google) using "q=" to get the search string and then explode that using "+" to get the actual phrase or something similar. Something a little more sidebar friendly (for someone who wanted to show recent google searches without having to decipher it.)

Cool.

8 | Jennifer

May 14th, 2002 at 7:13 am

Avatar

I had thought about that, but couldn't find a consistent pattern in the links…

sometimes it's q= keyword+keyword &hl=en

sometimes it's client=googlet&q= keyword

sometimes it's hl=en&q=keyword + keyword…

There's other ways the link comes in too

I looked online to see if there was any explanation to what all that means in the link, but couldn't find anything.

9 | kristine

May 14th, 2002 at 8:05 am

Avatar

You rock! This is how it worked in my head, and I just don't have the background knowledge to actually do this. But it makes perfect sense when I read what you did. :giggle: That's neato!

Karla, I would guess you could use Jenn's original tip for blocking bots from the lgf script and use google.com as a site to ignore. :)

10 | Brad

August 29th, 2002 at 1:11 am

Avatar

I don't s'pose you could give us just a little clue as to what you did to get them to display like that… even a vague hint??

11 | Jennifer

August 29th, 2002 at 11:35 am

Avatar

Ok…. if one of these original authors has a problem with this, please email me, and I'll take it down.

here's the hack to list just the keywords from google

12 | Brad

September 9th, 2002 at 7:01 pm

Avatar

Your the bestest Jennifer! :-)

13 | Jennifer

January 29th, 2003 at 1:04 pm

Avatar

Folks – there's a newer, better version here that will show keyword refs from almost ANY search engine:

http://www.scriptygoddess.com/archives/003277.php

14 | Jennifer

August 3rd, 2003 at 8:13 pm

Avatar

The link isn't working on "how to get html pages to process like they're php pages". Anywhere else I can find how to do this?

15 | Jennifer

August 3rd, 2003 at 8:41 pm

Avatar

Made a post here too on how to do that (html to process like PHP):

http://www.scriptygoddess.com/archives/003661.php

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements