Elliott C. Back: Technology FTW!

Wordpress From Where

Posted in Blogging, Code, Plugins by Elliott Back on July 23rd, 2005.

WP-From/Where is a brand new Wordpress 1.5 compatible plugin that logs search engine traffic to your site and displays a list of clickable keywords that people have used to get to your site! For example, on this post about homeless photography, I’ve gotten visitors from the following keywords:

Wordpress From Where

Download:

You can get the latest version of this plugin from its repository page. You can also download the file directly.

Installation:

To install this plugin, simply upload wp-from-where to your wp-content/plugins/ and activate in the admin interface. It’s a one-click install!

Usage:

After the plugin is installed, it will begin logging records immediately. However, to display them, you’ll need to call a defined function. For example, in my sidebar.php file, I have the following:

<?php if(is_single()) { ?>
	<div class="line"></div>
	<h3><?php _e('You Came From'); ?></h3>
	<ul>
		<?php wp_from_where
		(true, 'DESC', 20, '<li>', '</li>', '') ?>
	</ul>
<?php } ?>

You need a call to wp_head(); somewhere in your header.php file for it to log to the db properly. The function wp_from_where takes the following arguments:

  1. boolean $per_post, true if you want to display these per_post, false if you want a total across all posts.
  2. enum $sort = (’ASC’, ‘DESC’), defaults to ‘DESC’ to list highest hit-rate keywords first.
  3. int $limit, defaults to showing 10 items at a time.
  4. string $before, defaults to the blank string, prepends each item.
  5. string $after, defaults to the blank string, appends each item.
  6. string $sep, defaults to a space-comma, goes in between each item.

Update:

The latest version indexes both the post_id and the keyword for much better performance. I have about 25,000 items in my production db right now, and my blog was becoming uncommonly slow. With the new index, everything’s back to normal! Why, you wonder? The queries match both post_id and keyword per user hit, which, as you can imagine, is quite a bit. Now we should be scalable again.

This entry was posted on Saturday, July 23rd, 2005 at 8:47 pm and is tagged with search engine traffic, homeless photography, div class, blank string, admin interface, time string, h3, quot, comma, desc, lt, wp, repository, indexes, sidebar, logs, queries, ul, blog. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback.

Viewing 10 Comments

 

Trackbacks

(Trackback URL)

close Reblog this comment
blog comments powered by Disqus