bstat Beta 1 Release

UPDATE: bstat has been updated.

I’ve finally added a clean admin interface to my bstat WordPress stats tracking plugin and cleaned up the code for release as a public beta.

Quick Start Installation

  • Download and unzip bstat.zip
     
  • Place bstat.php in you wp-content/plugins directory
     
  • Place spacer.gif in your wp-content directory
     
  • Log in to your WordPress admin panel and activate the plugin, then visit the new bstat submenu of the options tab. This will allow bstat to create its database tables.
     
  • Add the bstat_hitit function to the footer.php of your theme (or in some other place where it will be called once for each page load). This starts the counting; you can see the results in the bstat submenu of the manage tab of the WordPress admin panel.

In order to view the bstat results on your public pages, you’ll need to the bstat display functions to your pages.

Using bstat Functions

  • bstat_hitit

It is essential that bstat_hitit be activated once (and only once) for every page load. In most themes (including the default and classic), it works perfectly when added to the bottom of the footer.php file.

<?php // this is the part that makes the bstats plugin work...
	global $id;
	if (is_home()) $id = 0;
	bstat_hitit($id, “read”);
	?>

(be careful of any “curly quotes” that might have been inserted in code samples)

Other functions are used to display lists of top stories, recently commented stories, recent comments, recent incoming search terms, etc. Most of these functions take similar arguments and output their results in similar ways.

Today’s Stats

  • bstat_todaypop
  • bstat_todayrefs

The functions bstat_todaypop and bstat_todayrefs each take the same arguments.

Usage:

bstat_todaypop({count}, “{before}”, “{after}”);

count is the total number of results to output

before is a string to output before each result

after is a string to output after each result

Example:

<h2>
  Today's Most Popular
</h2>


<ul>
  <?php bstat_todaypop(15, “<li>”, “&lt;/li>\n”); ?>
</ul>

Recent Stats

  • bstat_recentpop
  • bstat_recentrefs

The functions bstat_recentpop and bstat_recentrefs each take the same arguments.

Usage:

bstat_recentrefs({count}, “{days}”, “{before}”, “{after}”);

count is the total number of results to output

days is the number of days back to look

before is a string to output before each result

after is a string to output after each result

Example:

<h2>
  Incoming Search Terms This Week
</h2>


<ul>
  <?php bstat_recentrefs(15, 7, “<li>”, “&lt;/li>\n”); ?>
</ul>

Recent Discussion

  • bstat_discussionbypost
  • bstat_discussionbycomment

The functions bstat_discussionbypost and bstat_discussionbycomment each take the same arguments.

Usage:

bstat_discussionbypost({count}, “{before}”, “{after}”);

count is the total number of results to output

before is a string to output before each result

after is a string to output after each result

Example:

<h2>
  Incoming Search Terms This Week
</h2>


<ul>
  <?php bstat_discussionbypost(15, “<li>”, “&lt;/li>\n”); ?>
</ul>

Special Functions

  • bstat_refsforpost

Usage:

bstat_refsforpost({post_id}, “{before}”, “{after}”);

post_id is the post_id for the story, usually provided by a WP variable

before is a string to output before each result

after is a string to output after each result

Example:

<h3>
  Top incoming search terms for this post
</h3>


<small><?php bstat_refsforpost($id, “ ”, “ -”); ?></small>
  • bstat_pulse

Usage:

bstat_pulse({post_id}, {max_width});

post_id is the post_id for the story, usually provided by a WP variable

max_width is the maximum width the graph maw run

Example:

<h3>
  Story pulse
</h3>


<div style='height: 110px; text-align:center;'>
  <?php echo bstat_pulse($id, 525); ?>
</div>

<br />

Function Descriptions

  • bstat_hitit The hamster on a wheel that makes it all work. It records hits for each page load, and hits for each incoming search term.
     

    • bstat_todaypop displays top stories for today only.
       

      • bstat_recentpop displays top stories for the past x days. This function reveals more useful data on sites with low traffic, but is somewhat slower than bstat_todaypop.
         

        • bstat_todayrefs displays top incoming search terms for today only.
           

          • bstat_recentrefs displays top incoming search terms for the past x days. This function reveals more useful data on sites with low traffic, but is somewhat slower than bstat_todayrefs.
             

            • bstat_refsforpost displays all incoming search terms for a specific post.
               

              • bstat_discussionbypost displays recently commented posts. Each post will appear only once.
                 

                • bstat_discussionbycomment displays recent comments (and commenter). Better on sites with lots of community interaction.
                   

                  • bstat_pulse displays the “pulse” graph of hits over time.

                  Options

                  The bstat submenu of the options tab has two configurable settings:

                  • Make accurate pulse graphs The graphs look best when you’ve got a few months of history to feed them. To fill out the graphs for new stories (and when you’re new to bstat), the pulse function will do some simple interpolation. The question here is if you want it to look jittery (and somewhat less accurate) or smooth (and more accurate). I prefer the jittery look, but you can do what you want.
                     

                    • Filter incoming search terms using comment moderation and blacklist words. Referrer spam is as much of a problem as trackback spam. There are a few tricks in bstat to prevent the problem, but here’s one you can configure. Selecting this option tells bstat to not display search terms that contain words in your moderation list or blacklist.