My company uses WHMCS to manage hosting accounts. While preparing for new marketing ideas, I knew we had a lot of loyal customers but never really had the urge to check them. In order to make my life easier, I’ve created a report script to generate the customer retention graph.

This script will search through the database for active user and order them by registration year.

/*
*
* Author: Amirul Ali
* Website: www.ultraunix.net
* Description: Customer retention graph base on register date and domainstatus Active
*
*/

if (!defined("WHMCS")) die("This file cannot be accessed directly");

$description = "How many customer are still active since the year they register an account?";
$debug = true;

if ($statsonly) { return false; }

$chartdata = array();
// Listing all available years
$query = "SELECT DISTINCT YEAR(regdate) FROM tblhosting WHERE domainstatus='Active' ORDER BY YEAR(regdate) ASC";
$result = mysql_query($query);
while ($data = mysql_fetch_array($result)) {
$chartdata[$data[0]] = 0;
}

foreach($chartdata as $key => $value) {
$query = "SELECT COUNT(*) FROM tblhosting WHERE YEAR(regdate) = $key AND domainstatus='Active'";
$result = mysql_query($query);
while ($data = mysql_fetch_array($result)) {
$chartdata[$key] = $data[0];
}
}

$graph = new WHMCSGraphPie(600,200);
$graph->addData($chartdata);
$graph->setTitle("Customer retention graph");
$graph->setLabelTextColor("50,50");

Installation

  1. Download WHMCS: Customer Retention Graph
  2. Unzip the archive
  3. Upload the file into /modules/report/ folder
  4. Open whmcs and find “Customer Rentention” under graph section in Report page

Disclaimer

WHMCS is a complete Client Manager, Billing & Support Solution for Web hosting by WHMCS Limited. This graph plugin is an extension of WHMCS feature to provide custom reports. For more information please visit the report page. Please use at your own risk.

One thought on “WHMCS: Customer retention graph

Leave a Reply