Referrer Wordpress Plugin

Referrers is a plugin I coded to show the most recent referring urls to a particular post. I had seen the wp-refer plugin from NoPrerequisite but couldn't put it on my blog without hacking because it uses the meta fields to store its data, and as I display the metadata for other purposes in each post, it would get fairly cluttered.

Also, I am using the very good StatTraq plugin, so I thought I could make use of the fact that it already records referrers.

To install :

  1. Download and install Stattraq.
  2. Download post_referrers.php.txt
  3. Rename to post_referrers.php
  4. Or get the gzip file and uncompress it.
  5. Upload the resulting file to /wp-content/plugins
  6. Activate it in your admin interface

Using it is simple:

Add the following code to your index.php file, within the loop

 post_referrers(8, "<li>", "</li>", "No referrers", "self");

Where '8' is the number of referrers to show, '<li>' is the text to show before each link, '</li>' is the text to showafter each link, 'No referrers' is... you guessed it! the text to show when there are no referrers yet and the last option marks the excluded hosts. If you use 'self', internal referrers only will be hidden. Otherwise, you can write a list of hosts (domain names) to ignore like this: "google.com yahoo.com example. org" and so on...

See it work at the bottom of this page, and leave a comment in case of problems.

Version 0.21 and up use Google redirection to help prevent referrer spam.

En Français


13 comments about 'Referrer Wordpress Plugin'

Get the comments feed for this entry or post a trackback from your own blog

  1. 3 years, 9 months ago,

    [...] plugin to shows the last few referrers to each post, just like at the bottom of this page. Check it out! Articles similaires Jumble Up! Wordpress PluginStylesheet Choo [...]

  2. 3 years, 9 months ago,

    [...] ferrer slvShowNewIndicator(1096130516); Filed under: WordPress Plugins|Google it! Referrers is a plugin that shows the most recent referring urls to a particular post. [...]

  3. 3 years, 9 months ago,

    Thanks for the referrer plugin! I've been using Stattraq for a while, so it's great to be able to tap into all of that data ;-)

  4. 3 years, 9 months ago,

    [...] file in your post - formatted with line numbers, and a link to download the actual file. Referrer Will show the most recent referring urls to a particular post. [...]

  5. 3 years, 9 months ago,

    Referrer plugin pour Wordpress Je viens de trouver chez JFoucher un moyen d'afficher sous wordpress via le plug in StatTraq, les sites referrers (par lesquels un internaute est arrivé) sur une page d'un blog. La méthode est enfantine: Installer Stattraq. télécharger post_refer...

  6. Gravatar
    lee said:
    3 years, 9 months ago,

    Why does it show up after each post on my main page?

  7. 3 years, 9 months ago,

    lee, it sounds like you have the "related posts" bit in the wrong place... Look for the part that says something like "if comments or single" - put it in that section, not on the front page. Sorry - don't have the templates memorized, but dig around and you'll see it.

  8. Gravatar
    Jonathan said:
    3 years, 9 months ago,

    Hi Lee,

    You have to put an if condition like this : <?php if ($single) { ?> <ul> <?php post_referrers(10,"<li>","</li>","Not yet...","self"); ?> </ul> <?php } ?>

    That will display the referrers only if a single post is shown.

  9. 3 years, 8 months ago,

    [...] @ 21:47  (Current Mood: ) I like giving props where it’s due. So theReferrer Wordpress Plugin is a great way to show off those who send me traffic. Than [...]

  10. 3 years, 7 months ago,

    [...] ??? ??????? Filed under: WordPress — leepro @ 10:51 pm

            <a href=\"http://jfoucher.info/2004/09/24/referrer-wordpress-plugin/\">?????????? referrer??? </a>      
    
    
    
    
    
    Comments [...]
    

  11. Gravatar
    sum1 said:
    3 years, 7 months ago,

    well, but also it shows always the same referrers under every post. it doesn't distinguish between posts. can it also display post-secific referrers and not juast all of them without regard to which post they refer?

  12. 3 years, 6 months ago,

    [...] nt not supported - Type: 8 Name: #comment–> Polls Post Referrers ent not supported - Type: 8 Name: #comment–> StatTraq User [...]

  13. Gravatar
    Fletcher said:
    2 years, 11 months ago,

    Is it possible to group Post-Referrer? Sometimes my links are like

    index.php?=232

    and sometimes

    /archives/2005/07/slug

    I hope you know what I mean... :-)