The Yellow Llama | Web Design South Africa

BBClone & Wordpress Integration

BBClone is a rocking piece of software. Its a website statistics generator that provides highly detailed listings of each & every visitor to your site: their IP, Location, Time of Visit, OS, Browser, Time spent, Pages viewed, Referrer and Search Term used (if applicable).

bbcloneBasically you put a trigger on each page of your website. That trigger has a unique key/name that identifies that specific page so you can easily identify in the logs which pages have been viewed.

The Problem

It gets a bit tricky though, when you’re using templates like you have in Wordpress.

single.php is the template used for blog articles in Wordpress. That 1 file is used in the creation of 1000’s of blog articles. So how can you integrate BBclone with Wordpress so that you know which blog articles are being viewed?

The Solution

…Well let me first state that is isn’t the once-and-for-all-time solution to this problem. I’m sure that using the the_title(); tag, there is a better way, but until somebody shows me that way, I’ve found this way to work for me…and besides, its painfully easy.

Here’s the BBClone trigger

define("_BBC_PAGE_NAME", "Page Name");
define("_BBCLONE_DIR", "bbclone/");
define("COUNTER", _BBCLONE_DIR."mark_page.php");
if (is_readable(COUNTER)) include_once(COUNTER);

Generally, that piece of code goes onto your page and “Page Name” becomes the unique identifier in the BBclone logs.

Here’s what you do so that you can dynamically create a unique identifier based on the URI of your blog article…

define("_BBC_PAGE_NAME", $_SERVER['REQUEST_URI']); 
define("_BBCLONE_DIR", "bbclone/");
define("COUNTER", _BBCLONE_DIR."mark_page.php");
if (is_readable(COUNTER)) include_once(COUNTER);

Presto. Done.

That’ll generate a unique identifier from the URI (or in Wordpress lingo, the ’slug’) of your page. So in my BBclone logs for this post, I’ll see /bbclone-wordpress-integration/.

Ja I know its not pretty, but for now it does the job just dandy :)

3 Responses to BBClone & Wordpress Integration

  • Written by: burclar
  • Date: November 11th, 2007
  • Time: 4:07 am

great post thank you man

  • Written by: unodj
  • Date: March 23rd, 2008
  • Time: 1:45 pm

for nice titles in the stat list, use this code :)

function nice_bbc_titles() {
$uri = !empty($_SERVER[’REQUEST_URI’]) ? $_SERVER[’REQUEST_URI’] : “index”;
$uri = strtr(strip_tags($uri), array(”\r” => “”, “\n” => “”, “\\” => “/”));
$uri = str_replace(”$”, “$”, htmlspecialchars($uri, ENT_QUOTES));
$uri = trim(substr($uri, 0, 256));

if (!is_string($uri) || empty($uri) || ($uri == “/”)) return “index”;
$uri = (substr($uri, -1) == “/”) ? substr($uri, 1, -1) :
((($dot = strrpos($uri, “.”)) !== false) ? substr($uri, 1, –$dot) :
substr($uri, 1));
$uri = strtr($uri, array(”/” => ” :: “, “_” => ” “, “-” => ” “));
return ucwords($uri);
}

# actual code
define(”_BBC_PAGE_NAME”, nice_bbc_titles());
define(”_BBCLONE_DIR”, “bbclone/”);
define(”COUNTER”, _BBCLONE_DIR.”mark_page.php”);
if (is_readable(COUNTER)) include_once(COUNTER);

  • Written by: Jaymus
  • Date: April 11th, 2008
  • Time: 10:25 am

Good suggestions, I think I like what I found over here more: http://www.iltchev.com/?page_id=11

backup: http://wordpress.org/support/topic/116866?replies=5#post-731227

Leave a Reply



Blog News & Articles

What’s being loaded into this plane?

Its a hard disk in 1956.... HDD with 5MB storage in 1956. In September 1956 IBM launched the 305 RAMAC, the first computer with a hard disk drive (HDD). The HDD weighed over a ton and stored 5MB of data. Start appreciating your 1 GB memory ...

The WordPress Guru is launched

For the last 4 or 5 years that I've been using WordPress, I've managed to pick up a good few tips and tricks. 90% of my clients are sites who require content management systems, not blogs. And thus I've been able to create highly tweaked ...

A blind man wanders into an all-girls biker bar by mistake…

A blind man wanders into an all-girls biker bar by mistake. He finds his way to a bar stool and orders some coffee. After sitting there for awhile, he yells to the waiter, 'Hey, you want to hear a blonde joke? The bar immediately falls absolutely silent. ...

Looking for trouble…

Best part is when the dog looks up at the cat like... WTF are you doing...

26 Reasons why dogs bite people

...

Examples of Kulula attendants’ sense of humor

Kulula is an Airline with head office situated in Johannesburg. Kulula airline attendants make an effort to make the in-flight "safety lecture" and announcements a bit more entertaining. Here are some Real examples that have been heard or reported: On a Kulula flight, (there is no assigned seating, ...

News From Around