bstat Beta 3 Release

UPDATE: bstat has been updated.

Beta 2 never went public. This is beta 3.

Changes

This documentation supersedes any previous documentation.

The bstat_pulse() function has been improved and now uses your CSS for appearance. Call bstat_pulse_style() to add my default styles inline if you don’t want to modify your CSS. Also, bstat_pulse() now has two switches to control what it displays. Please take a look at the usage guide below for how to call this function now.

Also, take note of new example of how to call the bstat_hitit function: “if(is_home())” has changed to “if(!is_single())”. This corrects a problem with the way bstat was recording activity on any page with more than one story (search, archive, etc).

The next two features are for Zach. Links generated by the functions now use your WordPress permalink preferences instead of the ?p=XXX stuff.

It is now possible to exclude certain IP numbers from your hit counting. You’ll see controls for this in the bstat submenu of the options tab.

Search engine highlighting snuck into the last release, but has been buggy for some. It’s disabled in this release and will eventually be folded into a new plugin called bsuggestive. Yes, it’s bsuggestive. If you’d like to play with it, you can uncomment the likely looking line at the bottom.

There’s some ad tracking code in there, but I’m leaving it undocumented for now.

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_single()) $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>", "</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>", "</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>", "</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>All incoming search terms for this post</h3>
<small><?php bstat_refsforpost($id, " ", " -"); ?></small>
  • bstat_pulse

Usage:
bstat_pulse({post_id}, {max_width}, {display_text}, { display_credit});

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
display_text (acceptable values: 0 or 1), switch to display stats for total views and average views per day
display_credit (acceptable values: 0 or 1), switch to display “powered by bstat” credit

Example:

<?php bstat_pulse_style(); ?>
<h3>Story pulse</h3><?php bstat_pulse($id, 525, 1, 1); ?>

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.

  • bstat_pulse_style

    outputs an inline stylesheet for use with bstat_pulse. Suggestion: activate this to see what the default styles are, then add them to your site’s stylesheet and work from there.

Options

The bstat submenu of the options tab has three 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.

  • Ignore hits from these IP numbers.

    Sites with low traffic may find that activity by authors severely skews the stats tracking. Enter an IP address here to ignore it.

Tags: , , , , , , , , , , , , , ,

12 thoughts on “bstat Beta 3 Release

  1. Pingback:   Wordpress Plugin: bStat by Blogging Pro

  2. Pingback: WordPress Italy » Blog Archive » Plugin WordPress: bStat Beta 3

  3. Is this where you want bug reports? In the bstat submenu of the manage tab, the links under “Top (Non-Search Engine) Referrers” broke when I upgraded.

    I *think* I fixed this without causing any new problems by changing line 566 of bstat.php to read:
    $url = ($baseurl . ($row->url));

  4. Pingback: MaisonBisson.com » Blog Archive » bStat Features

  5. Hi,

    got this error message when I installed your plugin in my wp 1.51 blog under top stories, top referrers and pulse any suggestions?

    Pete

    WordPress database error: [Table ‘creation.wp_bstat_hits’ doesn’t exist]
    SELECT a.post_id AS post_id, LEFT(b.post_title, 60) AS title, ROUND((SUM(a.hits_reads)) / ((TO_DAYS(NOW()) – TO_DAYS(MIN(a.bstat_date))) + 1)) AS sort_order, CONCAT(‘
    Tot: ‘, SUM(a.hits_reads), ‘, Avg: ‘, ROUND((SUM(a.hits_reads)) / ((TO_DAYS(NOW()) – TO_DAYS(MIN(a.bstat_date))) + 1)), ‘, Max: ‘, MAX(a.hits_reads), ”) AS note FROM wp_bstat_hits a, wp_posts b WHERE a.post_id = b.ID GROUP BY a.post_id ORDER BY sort_order DESC LIMIT 50

  6. Pete,

    the error you mention is because the plugin hasn’t created its tables yet. Take a look at step 4 in the quick start directions above and be sure to follow the bit about going to the bStat submenu of the options tab.

  7. Hi,

    Two things. I have an odd error. The bstat tab in both the Manage section and the Options seems to want/have to be the last tab. If i have another plugin that comes after it, the bstat tab just displays the content of that other plugin. In my case, i have Photopress installed. With the photopress tab present, the bstat tab displays the photopress info. If i disable the last plugin, making bstat the last tab, it works fine.

    Also, is there a way to just display the number of views of a page on that page? I mean, i would like to have “Viewed xxx times” at the bottom/top of each blog article, rather than the graph.

    Ta

    Olly

  8. Fatal error: Cannot redeclare bstat_add_menu() (previously declared in c:\wamp\www\pixelficker\wp-content\plugins\bstat\bstat.php:40) in c:\wamp\www\pixelficker\wp-content\plugins\bstat\bstat.php on line 39

  9. Pingback: » Another Nice Touch: Right-Click For Error Code »  InsideMicrosoft - part of the Blog News Channel

Comments are closed.