Setting up the LGF Referrer Script on MT

Advertisement


I wrote this up for someone today, so I thought I'd post it here as well in case someone is looking for step-by-step instructions for installing the LGF Referrer Script (link on the left sidebar under "Scripts") in movabletype. This is a php script, so you must be able to run that. Also, it requires that the page you want to track referrers to be php (ie. index.php). Instructions follow:

Instructions for Installing LFG-Referrers Script.
(available from http://littlegreenfootballs.com)

1. Download script and unzip.

2. Unzipped folder should contain 6 files including:

example.php
readme.txt
semaphore.ref
lgf-reflog.php
reflog.txt
show-refs.php

3. Upload reflog.txt and semaphore.ref to the directory where your index files are located. CHMOD both of these to 666.

4. Open up lgf-reflog.php in a editor and look for the variable "$mydomain = 'mydomain.com';. Change mydomain.com to the name of your domain, without the http://www. part. It should look like this:

$mydomain = 'fortysomething.ca';

Be sure that you retained the single quotes around it and the semi-colon at the end of the line.

Save and close this file.

5. Upload lgf-reflog.php to the same directory that you uploaded reflog.txt and semaphore.ref to. No CHMOD change is required.

6. All done ftp-ing files to your server. Moving over to Movabletype files now.

7. Open up your movabletype Main Index Template file.

8. At the very top of the page (before the DOCTYPE declaration etc.), paste this code into the top of template body:

<?php include('lgf-reflog.php'); ?>
Save and close this file but don't rebuild just yet.

9. In movabletype templates section still, click Create New Index Template.

Template Name - Referrers
Output File - referrers.php

Paste this code into the Template Body: (this is just the code from the LGF file "show-refs.php" that is in the unzipped LGF folder)

<?php /* -------------------------------------------- LGF Referrer Log Display Page By Charles Johnson Copyright 2001 LGF Web Design All Rights Reserved. http://littlegreenfootballs.com

This file may be freely distributed
as long as the credits and copyright
message above remain intact.
--------------------------------------------
*/

// Name of referrer log file
$reflog = "reflog.txt";

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>Last 50 Referrers</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
body {
background-color: #FFFFFF;
}
p {
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 10px;
line-height: 14px;
color: #000000;
}
</style>
</head>

<body>
<?php
$rfile = file($reflog); // read the referrer log into an array
echo "<p>\n";
foreach ($rfile as $r) { // loop through the array
$r = chop($r); // remove trailing whitespace
if ($r <> "Direct request") echo "<a href=\"$r\">$r</a><br />\n"; // if not a direct request, link it up
}
echo "</p>\n";
?>
</body>
</html>

Save and then rebuild all index files.

10. You should now have a new file on your server called referrers.php in the directory where your index file is. You can check this new page by opening it up in your browser by typing in, for example, http://www.fortysomething.ca/referrers.php . It will probably be a blank page at this point (no referrers logged yet), but you should see that the Title Bar says "Last 50 Referrers".

11. Now, you'll maybe want to wait a bit until some referrers actually get logged onto this page. Just keep checking it for a bit until you see a referrer listed so you know it is working ok.

Once it's working, you can set a just set up a regular link to this new page from your main index page (or where ever you'd like to link to it from). Of course all this assumes you want to have your referrers displayed on a separate page. You could also do a php include of referrers.php anywhere in your blog. Also, you can format the referrer page by adding your own CSS styles to the referrer.php template.

12. One last thing, there is a hack to this script that will produce the date and time of the referrer available from scriptygoddess, if you want to add that feature. There are also hacks there for logging google referrals separately and excluding certain referrers from the referrals listings.

November 20, 2002 in Scripts and Software

Search etc.

More Entries From Scripts and Software

10 Awesome Techniques and Examples of Animation with jQuery Six Revisions takes a look at how to introduce animation into designs with the help of jQuery. In this article, we share with you... (November 2, 2009)

Two Nice Scripts for Rotating Image or Content Display Two nice script today, for displaying rotating images or content: Create a Simple jQuery Carousel (Quesness) Create a Horizontal Accordian with Ajax (Dynamic Drive)... (October 29, 2009)

Create a Fancy Share Box ... and more! Using CSS and jQuery, turn an unordered list into a fancy "Share This" box. A nice "how-to" for a good looking share display.... (July 13, 2009)

Simple Page Peel Effect with jQuery and CSS (and more Javascript resources) From The Art of Hand Coding, a nice "how-to" create a trendy "page peel" effect using jQuery and aided by a little CSS. Simple... (May 11, 2009)

Minimalist jQuery: 11 Useful Plugins under 4K It's easy to be wowed by all the great jQuery plugins out there but some of them are pretty heavy and can really slow... (April 23, 2009)

Curon Vs. Typeface.js, Which One is Better? Kilian Valkhof has a nice article comparing the two fairly recent font-replacement scripts Cufon and Typeface.js. The article details how both scripts work, their... (April 22, 2009)

25+ jQuery Plugins To Enhance HTML Site Queness.com has a nice round-up of jQuery plugins that can enhance and beautiful html elements, such as forms, file uploaders, auto complete, calendars,... (April 16, 2009)

GalleryView jQuery Plugin GalleryView is a nice jQuery based image gallery plugin with a ton of features and customizing options. The author has taken some time to... (April 16, 2009)