Referer – Wordpress Plugin
Warning: This plug-in is now unsupported. I haven’t had time to develop it for a while, and I can’t see that changing any time soon. If anybody wishes to do something with this then by all means be my guest.
Description »
Referer [sic] is a plugin for the popular blogging software WordPress. It allows you to display information about refers you have had from other websites. Currently available stats are Top URLs, Top Hosts Top Search Keywords, and Top Search Phrases. Basically these show how many people have clicked through from a given website and what people are searching for to find your website.
You can see this plugin in action at the bottom of my right-hand sidebar (see http://kitty0.org/blog/).
I know it’s spelt wrong but somehow that is the spelling used in the HTTP/1.1 Specification (RFC 2616) so I guess it is now the official spelling when describing “the address (URI) of the resource from which the Request-URI was obtained.”
Copyright / Disclamer »
Copyright (C) 2006 Hamish Morgan (referer [at] kitty0 [dot] org)
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
FURTHER MORE this plugin may well corrupt your website, empty your database, delete the internet, run away with your girlfriend, instigate World War III, email your porn collection to your Mum, and perform satanic rituals to further the coming of Demonic Minions and general Armageddon. USE IT AT YOUR OWN RISK! You have been warned.
Design Goals »
- Display a list of Urls and Hosts on a Wordpress blog to show where people have clicked though from to find the site.
- Display a list of Search Words and Phrases that where used in a search to find the site.
- Allow this display to be easily customized without the need to edit any files.
- Log the referering url every time a page is loaded.
- To quickly fill out the logged data with data recorded previously by allowing a webserver access log to be imported.
- Provide some means by which results can be filtered out by URL, Host, or Search Word to counter the increase is referer spam.
- Allow the site owner to browse and manage logged data in detail.
Download »
This plugin is in very early Alpha version. It has several bugs that I am aware of and probably many others that I am not. I distribute it in the hope that it will be useful, but WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY or FIRNESS FOR A PARTICULAR PURPOSE. It may well corrupt your website, empty your database, delete the internet and run away with your girlfriend. Use it at your own risk!
The latest version is 0.41 but if you wish you may download an earlier version:
- Version 0.41 —
referer_v041.tar.gz. - Version 0.40 —
referer_v040.tar.gz. - Version 0.30 —
referer_v030.tar.gz. — view source - Version 0.21 —
referer_v021.tar.gz. — view source - Version 0.20 —
referer_v020.tar.gz. — view source - Version 0.10 —
referer_v010.tar.gz. — view source
Installation »
- Extract the contents of the archive to your wp-content/plugins/ directory, creating a new directory: wp-content/plugins/referer/
- Make sure all these files are readable by the webserver. (See http://codex.wordpress.org/Changing_File_Permissionsread)
- Go to the “WordPress Admin -> Plugins” panel. Find the Referer plugin in the list and click “Enable” in the right-hand column.
- Go to “WordPress Admin -> Options -> Referer” and click Install. You should now see the plugins Options page.
- Add referer_topReferers() function to your template. This will display referer stats on your blog. If you have a custom template I can’t describe exactly what you should do but here is what you should do if you are using the WordPress default template.
- If your template files are writable on the server then login to WordPress Site Admin and go to Presentation -> Theme Editor. Otherwise you will have to edit the file on you computer and upload it to the correct location on your server.
- In Theme Editor click “Sidebar”. Or localy open /wp-content/themes/default/sidebar.php.
- Insert ” <li> <?php referer_topReferers(); ?> </li> ” at the bottom of the page just before the ” </ul> </div> ” tags. It should look something like this:
<li> <?php referer_topReferers(); ?> </li> </ul> </div>
- Click “Upload File” to save your changes. Or locally save the file and upload it.
- Done! Browse to your blogs front page and you should see the Top Referers stats box in the bottom right-hand side of your side-bar.
Upgrading »
- Extract the contents of the archive to your wp-content/plugins/ directory, creating a new directory: wp-content/plugins/referer/
- Go to “WordPress Admin” -> “Options” -> “Referer” and click “Migrate”.
- If you are upgrading from version 0.10 you will need to configure your template as described in Installation Item 5.Download and extract the latest version of this plugin (above.)
Problems (Help!) »
So it isn’t working as expected. Well first go and read the last paragraph of the Copyright / Disclaimer (above) …and your back. See I told you so.
If you would like my help with a problem then, to speed up resolution, please:
- Insure you are using the latest version of this plugin.
- Tell me about your server: What version of PHP, MySQL and WordPress you are using? Is it Apache on Linux, or IIS on Windows?
- Explain step-by-step exactly what happened up until the problem occurred.
- List all your installed Wordpress plugins with version.
- Provide a link to your blog and, if possible, to the page with the error.
Related Links »
- http://www.wpplugins.jp/projects/analyze/referer/
Japanese translation of the plugin. - http://mhdland.net/blog/index.php/2006/08/31/hamishs-referer-sidebar-widget/
Sidebar Widget for the referer plugin written by Huda. - http://www.ozpolitics.info/blog/?p=32
Bryan’s BDP Referral Tracker plugin. Very similar plugin mine but has slightly different strengths.
Change Log »
Version 0.4 -> 0.41
- Fixed call-time pass-by-reference bug that showed under some PHP5 configurations.
Version 0.3 -> 0.4
- Split the plugin into many smaller files because ~250k of code in one file is just silly.
- Put all the css into a seperate style sheet.
- Added Manage options subpage which allows you to view and manipulate stored referer records.
- Moved Log upload controls and other operations to Tools options subpage.
- Removed %n% tag from the page template description because it isn’t very important.
- Added DHTML Date/Time Selector by dynarch.com to Manage subpage.
- Fixed bug where rows from imported log files would use the current date not the logged date.
- Simplified default display templates, because they where confusing and where cause problems with IE (suprise suprise)
- Complete re-write of log import functionality. Now has the ability to set any valid CustomLog directive to parse the log by.
- HTTP Referer is processed after the page has been outputed to the client so it doesn’t slow the page load time.
- Fixed bug where not all SQL was escaped properly.
- Now Strips cache:llO61WBwk4wJ:example.org/ strings from search queries.
- Default value of Blacklist Search Hosts option is now off.
- Added AOL Search to default Search Engines list.
Version 0.21 -> 0.3
- Added rel=”nofollow” to all generated links, so referer spammers dont get any pagerank for their trouble.
- Added “Clear Logged Data” button to empty the referers data table.
- Added GZip (.gz) compressed log file upload. (Not .tar.gz though.)
- Added error checking for client-side form post failures.
- Added disable on submit to options forms so it doesn’t get borked by users epileptic-clicking.
- Added ability to import logs from a server path.
- Hitting [Enter] key in the Options page now runs “Update Options” not “Restore Defaults”.
- Max-upload in label for “Log File Upload” is now in human readable units.
- Simplified the default display templates.
- Fixed some HTML bugs in Options page.
- Fixed bug where limit argument in topReferers() functions doesn’t update %*-limit% tag.
- Fixed multilingual character support in search words and phrases.
- Fixed bug where uploading files larger than max upload file size sometimes just reloads the page with no error.
Version 0.2 –> 0.21
- Fixed bug where Host Blacklist didn’t blocks URLs.
- Fixed/Enabled Searchengine Host Blacklisting
- Improved default output format templates.
- Added %snip% element to output format.
- Fixed problem where stats titles could say “Top 0 Referers”
- Fixed problem with submitting forms containing HTML entities (eg )
- Fixed typo in function referer_fetchPhrases()
- Function parseReferer now returns an associative array of referer info.
- Add migration supportto make upgrading easier.
- Fixed bug where empty lines in searchengine RegEx caused an error.
Version 0.10 –> 0.20
- Added Search Phrases.
- Added complete URL logging.
- Changed database structure to use one table for all data.
- Added search word blacklist
- Improved default format strings for all data types.
- Improved configuration options sub-panel layout.
- Re-wrote almost everything to better accommodate new and upcoming features.
- Removed all fatal errors.. so if something goes wrong it should at least still be possible to disable the plugin.
Known Bugs
- In KHTML (Konqueror / Safari) does strange things with <abbr> tags.
- Long strings in the Manage page are broken up by font-size:0 spaces so copy/paste doesn’t work properly. Additionaly it is malformed XHTML because empty tags should be stripped. Alternative solutions like <wb />, and Unicode U+200B (zero width space), or normal spaces have their own cavetes.
- In Manage page Search Words and Phrases are wrapped even if it is wraping on a whitespace. Very minor but anoying.
- Not exactly a bug but I don’t have access to IE so no doubt everything gets garbled by that poor excuse for a browser.
- Importing a malformed log file can throw many, many errors.
- In Options that Display Format Templates are sometimes reported to have been saved even if no change has been made. This is due to varying new line encoding on different platforms.
- Manage Admin page style is inconsistent with rest of Admin.
Roadmap (TODO)
- Implement a “Reprocess logged data” tool to update data against new filters and blacklists.
- Rewrite all string/regex functions to be mulltibyte safe.
- Fuzzy match domain names in URLs (e.g www.example.com and example.com should be grouped.)
- Improved and easier searchengine matching. Possibily defined as a host and a query identifier. e.g: For google: host=”/www.google..+/search/”, query=”/[?&]q=([^&])&/”
- Or better yet host=”www.google”, query=”q” but the problem with the latter is it doesn’t cope with dogpile style urls: “search/blah/-/-/-/”
- Log local searches
- Add many more search engines. E.g: excite, hotbot, dmoz, aol, a9, technorati, altavista, images.google, dogpile, beta.search.msn, lycos, metacrawler, alltheweb, vivisimo, wisenut, gigablast, mamma, looksmart, search. netscape, clusty, about.com, iwom.ask, webcrawler.
- Add “Clear” button to filters in Manage page.
- Replace the error handling class with something less um… crap.
- For log parsing use ApacheLogRegex::parse_n() to improve performance.
- Add tooltips to result hheaders and clickable results in Manage page to give some hint as to what will happen if clicked.
- Search words and phrases sometimes contain erroneous punctuation.
- Add ability to delete (not just hide) records from the manage page.
- Clarify deffinition of hiding, deletion, and blacklisting (when logging or when displaying) And alter respective controls.
- Install and Mirgate should happen automatically
- Referers page template (like links template)
- Localization / I10n
- Run as a Wordpress Widget
- Current HTTP_REFERER Referer search word highlighting.
API Function Reference »
The following functions can be used in your template files to include referal statistics.
string referer_topReferers([integer limit [, boolean echo]])
This is a wrappers for a function in the Referer class. Use it in your template to print a formated listst of top referers by catagory. This will display all usefull information in a box and should be the only function you have to include in your template. However if you wish to display only certain parts of the data or format it yourself use the
referer_top*()andreferer_fetch*()function below. They take the results of the all the other top*(function) functions (see below) and format it using the "referer" XHTMl snippets in the plugin options panel. It then outputs all the data into the page.Optional paramater $limit determins tha maximum number of results to return. If it is not given then it will return the number set in the plugin options panel. If limit is given as 0 (zero) the ALL results will be returned.
If you set option paramater $echo as FALSE then instead of print the results they will be returned so you can perform additional formatting or concatonate them with other data.
string referer_topUrls([integer limit [, boolean echo]])
string referer_topHosts([integer limit [, boolean echo]])
string referer_topWords([integer limit [, boolean echo]])
string referer_topPhrases([integer limit [, boolean echo]])
These are wrappers for function in the Referer class. Use them in you template print a formated lists of top referers.
They take the results of the fetch*() functions (see below) and format it using the XHTMl snippets in the plugin options panel. Then they output all the data into the page.
Optional paramater $limit determins tha maximum number of results to return. If it is not given then it will return the number set in the plugin options panel. If limit is given as 0 (zero) the ALL results will be returned.
If you set option paramater $echo as flase then instead of print the results they will be returned so you can perform additional formatting or concatonate them with other data.
array referer_fetchUrls([integer limit])
array referer_fetchHosts([integer limit])
array referer_fetchWords([integer limit])
array referer_fetchPhrases([integer limit])
These are wrappers for function in the Referer class. Use them in you template to get an unformatted array of results.
They query the database for stats about top referers. They return an array of urls, hosts, search words and searchphrases respectively. If there was a problem or if there are no results they return NULL.
Optional paramater $limit determins tha maximum number of results to return. If it is not given then it will return the number set in the plugin options panel. If limit is given as 0 (zero) the ALL results will be returned.


LinkedIn Profile
Facebook Profile
CV/Resume
hum… on my wordpress i can no more acess control panel of referer by Manage.. what could be?
I’m playing with this on my site now. I made the search keywords to refer to my own site in google, technorati, and yahoo search string and it’s working like a charm. thanks.
Is there a way to use this on a protected page (one made under Write/Write Page)? I’d prefer to have the stats only for my eye.
Hello, this is a great plugin! Thanks for releasing it. Secondly, is there a way to pull and display the title-names of the referers and have the URLs themselves appear as quicktips?
I activated this plugin, and it wiped out my blog and the admin. It displays blank now. Any ideas how to fix?
Hi there Nice plugin. I’d like to request a feature. Settings in admin should make it possible to display only the selected options in the result. Meaning; I’d like only to show ULS or Phrases or Hosts or … On my site, I’d like to show only display only "Phrases". How would I do that. Entering "0" (zero) in "Top Referers Limits", displays everything. What could I use now to display only the phrases ? Rgds Jakob http://www.boyer-draeby.dk/
Man, sorry, couln’t see the forrest for all the trees
Thx Jakob http://www.maxthon.dk (Demo)
I’d like however still to request nother feature (hope that I didn’t miss anything this time): The ability to display the "stats" on individual pages, so that the stats are shown on the right pages. Meaning…..: On a specifc page, only the referers to that page are shown, etc . Possible ? Rgds Jakob at http://www.maxthon.dk
Hmmm, I see now that you plugin can not handle danish characters like Æ, Ø, Å (the three extra danish characters)… Is there a way to change that ? Rgds Jakob
Great plugin, but i\’d like to suggest that there be an option to specify the server path to the logfiles.like just a textbox that you could enter /home/user/site/logs/access-log or whatever the path to the logs on your server so there would be no need to download them just to upload again.thanks for the plugin though, it was exactly what i was lookin for.
Hi! First of all GREAT plugin! I am trying to get it to work with swedish characters "encoding ISO-8859-1" (å, ä, ö)I tried the "Danish way" but then my site doens´t even load…. Any ideas on how to solve it?Thanks / Marcus
Hi HamishIs it possible to make the plugin register what pages referers are lead to ? I\\\’d like to show page specific referers. Meaning, on “page x”, I\\\’d like to show what referers lead to “page x”. Can this be done ?RegardsJakobhttp://www.isabells.dk
It would be great if there was an option to only show referers within the last 24 hours, like on the bottom of this page. This seems to have been a feature of WPMU 1.5, which is now gone.
i wanna know the coding of how to show the last visited page from which the current page is linked.
Actually I am in Chichester not Rochdale
I made sidebar widget for this plugin
It can be customized for title, referer shows up, output lines.
Hi, thanks for this plugin
I really like it! However, I\’ve found that everytime I save/update the options – it adds an extra after certain class definitions etc. – How can I prevent this? I\’m sure it doesn\’t make a huge difference except that for instance the class factor becomes something like: I\’m using Firefox 1.5.0.6. Thank you
Thank you very much!
This issue has now been resolved. Now I\’m trying to decide whether its good for my host to have magic_quotes turned on!:)
OMG… I can’t believe I was so silly! – in my haste to leave the messages I didn’t check my email address after typing it in the first time (and the cookies remembered my details for the second reply) – I have corrected it now and as you can see – the numbers are but right next to each other >_< Thank you very much for trying though! I do appreciate it and will contact my host to find out more about the settings.
hamish 0.41 made my int. settings f… up. national characters are messed up. the change mentioned up page, doesn’t apply anymore .. ? rgds jakob http://www.boyer-draeby.dk
Seems to be a good idea, but, all the words and phrases are NULL?
Suggestions.
I had to turn it off, the database will be grow way to fast.
1.) Need the Phrases and Words in the database instead of NULL.
2.) Need to have option for only the “visible” links inserted into the database. Otherwise the database will grow to large as it collects internal links.
Database grows
And I think it slows the site down ?
Cheers !
http://www.boyer-draeby.dk
hallo Hamish! i too would love to get this plug in “viewable by admin only” format!
possible to obtain a certain documentation stuff?
thanx a ton in advance!
Hi. Got a problem with your plugin. A very little one, but truly annoying for me. Your plugin’s output, the Search Phrases section, ain’t XHTML valid. You should encode the ampersands (all the “&” in the strings got from the search engines queries should be transformed when being outputted as “&”)
Er, sorry, it’s not in the Search Phrases, but in the Top Urls section. For example:
http://www.google.it/search?hl=it&q=uccidere+la+democrazia&meta=
should be encoded in
http://www.google.it/search?hl=it&q=uccidere+la+democrazia&meta=
Ho ho ho! It says I live in Oxford (still not anywhere as glamorous…)
congratulations for this plugin!
it is really useful..
but I wonder why your “Top 5 Urls” are adult sites… !?!?
I could not find any link to your blog on those sties
thanks
Can you develope a simple phpbb mod that do the same of it?
If you can help, contact me please.
i just installed this plugin on my blog and i love it! thank you!