Call us Toll-Free:
Email us

Tracking Retention in Google Analytics

Mike Peters, January 29, 2013    --    Posted under Analytics
Tracking retention rates or cohort analysis, is the best way to visualize your site's addict-ability.

User retention tends to be an area where people pay the least amount of attention, but I think is one of the most important to monitor. I would argue that the single most telling metric for a great product is how many of them become dedicated, repeat users.

If you fail to retain users over time, traffic will never generate a "snow ball" effect. Your glass-ceiling becomes limited to the arbitrage difference between the cost of traffic and ad revenues.

Focus on continually improving your retention rates and you'll be well on your way to building a mega successful site.

First step is to monitor your retention rate numbers. As they say - "What doesn't get measured, Doesn't get done".

The goal is to have the data you need to generate a cohort report like this one:

In this post, I'll describe how to use Google Analytics, for cohort analysis.

Don't be fooled by Google's Returning visitors numbers

Google Analytics appears to provide information about visitor retention through the New vs. Returning visitors report.

That report shows you the proportion of returning visitors. You could set your date range for January, note the percentage of returning visitors, and then set the date range for February, hoping that the percentage of returning visitors has increased.

But what happens if you retain all your January visitors, but drive a ton of new visitors to the site in February? Your proportion of returning-to-new visitors will go down even though you're retaining visitors!

Additionally, if your funnel involves users leaving the site (to "Facebook-Connect" for example), Google Analytics could confuse that with a user leaving the site.

Tagging visitors

For proper cohort analysis, we need a way to "tag" users, segmenting them into groups based on the date of first visit.

We'll then be able to look at the group of new users generated on a given month and see how long they stuck around:

Google Analytics custom variables and events, lets us put it all together.

Step 1 - Install Google Analytics

Signup for Google Analytics (it's free) and create an account for your site.

Add the Google Analytics code to all pages on your site.

Generally this means adding the code to your footer include file.

Step 2 - Pulse script

Save this script under the root folder of your site:


header('Content-type: application/json');

"if(typeof pulseCallback=='function')".
' pulseCallback({"pulse":"'.date('Y-m-d').'"});');

Note that I'm assuming your server supports PHP. If you're using a different server-side scripting language, find a geek who can help or contact us.

Step 3 - Store custom variable in Google Analytics

Add this javascript code to the footer of all pages:
function jsCreateCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString()}else var expires="";document.cookie=name+"="+value+expires+"; path=/"}
function jsReadCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i!=ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length)}return null}
function jsGetCookie(cvar, cval) { if (cval == undefined) cval = ''; return (jsReadCookie(cvar) != null && jsReadCookie(cvar) != '') ? jsReadCookie(cvar) : cval; }

try {
var checkpulse = jsGetCookie('checkpulse');
if (!checkpulse) {
// get timestamp
var s = document.createElement('script'); s.type = 'text/javascript'; s.src = ''; s.async = true;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(s);
} else {
channel = ""; // Update when using channels
$(document).ready(function () { _gaq.push(['_trackEvent', 'Pulse', checkpulse, 'Channel #'+channel]); });
} catch(err){}
function pulseCallback(o) {
jsCreateCookie('checkpulse', o.pulse, 365);

What we're doing here is - on every page load, check if the user was already tagged with a "create date".

If user not tagged yet - it's a new user, we connect to the server's pulse.php script and fetch today's date. The date is then stored in a local cookie named "checkpulse".

Finally, we pass the event to Google Analytics, incrementing a count for our user's "create date".

Crunching the numbers

Congratulations! Now you can finally track your real retention rates and build a cohort chart.

Login to Google Analytics, open "Traffic Sources", then "Events" - "Top Events"

Select the date range starting with the first month you're tracking (January in the example above) through today. Change the period to "Month" and select "Unique Events":

Hover above the chart and record the numbers for each of the months

Download sample Cohort report and populate it with your data. Pay attention to your user's average life time and variations in month-to-month retention rates.

Know your numbers.

Use your cohort report as a compass for whether or not you've created a great product that users love.

Sublime Text Editor for PHP - a love story

Mike Peters, January 24, 2013    --    Posted under Basics
Sublime Text is a fast, sophisticated text editor for code.

Over the years we've tested numerous text editors, including Notepad, Notepad++, PHPStorm, Eclipse, jEdit, NetBeans, phpDesigner and PHPEdit...

Up until recently, PHPStorm and Notepad++ were our two favorites.

PHPStorm has a very extensive feature-set: syntax highlighting, autocomplete, refactoring, html wysiwyg mode, a built-in debugger and file indexing. But it's heavy. Slow. Bloated.

Notepad++ is fast, but it's missing a lot of the goodies found in PHPStorm.

Introducing Sublime Text

Sublime Text 2 combines the best of both worlds:

* Blazing fast
* Sexy
* Syntax Highlighting
* Code completion
* Multi-select and multi-edit
* Goto Anything
* Find and Replace in files
* Customizable via extensive plugin library


Step 1

Download the latest version of Sublime Text 2 here

Windows, Mac OS and Linux binaries are available.

Step 2

Install the Sublime Package Control, by launching the Sublime editor, selecting "View" - "Show Console" from the menu, then pasting this code directly into the console:

import urllib2
,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen(''+pf.replace(' ','%20')).read()); print('Please restart Sublime Text to finish installation')

Package Control is now installed. Close Sublime text editor and restart it for changes to take effect.

Step 3

Open Sublime text editor, click Ctrl-Shift-P and type "Install Package"

Search and install these packages, one by one. Simply type the package name and click it to install.

* SublimeCodeIntel
* SublimeLinter
* WordHighlight
* jQuery
* Prefixr
* Clipboard History

One other thing you're going to want to turn-on is the "Auto save" feature. Off by default, you can turn it on, by opening the "Preferences" - "Default" and setting save_on_focus_lost to true:

"save_on_focus_lost": true,

Step 4

Sublime PHP linter relies on PHP being installed on your machine.

If you haven't installed PHP earlier, grab it from

You'll want to get the Thread-safe ZIP version. Extract the ZIP file to a new "C:\Program files\php" folder.

Open Sublime editor Preferences menu, select the SublimeLinter Settings under "Preferences" - "Package Settings", locate the "sublimelinter_executable_map" block and enter the full path where PHP is installed.

For example:
"php" : "C:\\program files\\php\\php.exe"

Step 5

Install Soda-Theme to give Sublime a sexy dark look

Once installed, update your default theme under "Preferences" - "Settings" with:

"theme": "Soda Light.sublime-theme",
"soda_classic_tabs": true

Restart Sublime editor and you're good to go

Sublime Cheat Sheet

Open Folder: Opens list of all files on a left pane
Ctrl-P: Quickly find any file under your project
Ctrl-F: Find
Ctrl-H: Find/Replace in current file
Ctrl-Shift-F: Find/Replace in files
Ctrl-M: Jump to closing bracket
Ctrl-Shift-M: Select all content of current bracket
Ctrl-Z: Undo
Ctrl-Y: Redo
Ctrl-G: Goto line
Ctrl-S: Save current file
Ctrl-R: Goto symbol / function definition
Ctrl-Shift-D: Duplicate line
Alt-Shift-2: Split to two panes (shift-1 back to one)
Ctrl-2: Jump to pane 2 (Ctrl-1 jump to pane 1)
Ctrl-Shift-L: Multi select
Alt-F3: Select all occurrences of current word for multi edit

View 1 Comment(s)

6 Months with GlusterFS: a Distributed File System

Mike Peters, August 9, 2012    --    Posted under Programming
Gluster is an open-source software-only distributed file system designed to run on commodity hardware, scaling to support petabytes of storage.

Gluster supports file system mirroring & replication, striping, load balancing, volume failover, storage quotas and disk caching.

Hesitant with the lack of glowing reviews about Gluster, we were attracted by its feature set and simple architecture.

Over the last six months, we battle-tested Gluster in production, relying on the system to deliver high-availability and geo replication, to power large scale Internet Marketing product launches.


The Gluster architecture aggregates compute, storage, and I/O resources into a global namespace. Each server plus attached commodity storage is considered to be a node. Capacity is scaled by adding additional nodes or adding additional storage to each node. Performance is increased by deploying storage among more nodes. High availability is achieved by replicating data n-way between nodes.

Unlike other distributed file systems, Gluster runs on top of your existing file-system, with client-code doing all the work. The clients are stateless and introduce no centralized single point of failure.

Gluster integrates with the local file system using FUSE, delivering wide compatibility across any system that supports extended file attributes - the "local database" where Gluster keeps track of all changes to a file.

The system supports several storage volume configurations:

* None: Files are transparently distributed across servers, with each node adding to the total storage capacity.
* Replica: Files are replicated between two LAN drives (synchronous replication)
* Geo replica: Files are replicated between two remote drives (asynchronous replication, using rsync in the background)
* Stripe: Each file is spread across 4 servers to distribute load.

As of October 2011, development of Gluster is funded by RedHat

Installing Gluster

This is one of the areas where Gluster really shines. You can be up and running in minutes.

Step 1

Installing the FUSE client, which serves as the "glue" between Gluster and your local file system.

tar xvfz fuse-2.9.1.tar.gz
cd fuse
make all
make install

Step 2

Building Gluster from source

tar xvfz glusterfs-3.3.0.tar.gz
cd glusterfs
make all
make install

Starting Gluster and setting it to auto-start on next reboot

/etc/init.d/glusterd start
/usr/sbin/update-rc.d glusterd defaults

Step 3

Configuring your first two nodes as a Replica setup (mirroring)

On node 1 (backup1east):


gluster peer probe backup2west

gluster volume create backup replica 2 transport tcp backup1east
:/gfs/bricks/vol0 backup2west:/gfs/bricks/vol0

-t glusterfs backup1east:/backup /gfs/backup

On node 2 (backup2west):


gluster peer probe backup1east

-t glusterfs backup2west:/backup /gfs/backup

Important: Make sure the name of your Gluster volume ('backup' in the example above) is different than the name of the share ('gfs' in the example above) or things will not work properly.

Our Experience

Going into this experiment, we had very high hopes for Gluster. Once proven, the goal was to replace our entire private cloud storage cluster with Gluster.

Unfortunately, we have been very disappointed with Gluster...

In spite of getting a lot of help from the Gluster community, testing different platforms and configurations, results have been consistent.

Like other users reported, we struggled with poor performance, bugs, race conditions when dealing with lots of small files, difficulties in monitoring node health and worst of all - two instances of unexplained data loss.

We ended up completely abandoning Gluster and switching back to our home-grown rsync-based solution.

As always, run your own tests to determine if this is a good fit for your needs.

Proceed with caution.

More Resources

* SlideShare Introduction to GlusterFS
* Gluster Documentation
* Gluster IRC Channel
* Gluster Blog

View 1 Comment(s)

Amazon AWS & EC2 are down... This is why you need redundancy

Adrian Singer, March 15, 2012    --    Posted under Get Online
Amazon AWS and EC2, are DOWN affecting an estimated 500,000 sites.

Twitter is buzzing with sysadmins, checkout pages are not coming up and millions of dollars lost.

Here at SPI, we believe in redundancy.

Our client sites are hosted with Rackspace, NTT Verio, Softlayer and iWeb... all at the same time, on a master-master setup.

They're all great hosting providers, but as our friends at Pingdom frequently report, if things can go wrong they will.

Replicating client sites across multiple data-centers with multiple non-related hosting providers, is the only way to deliver true 100% uptime across the board.

If your site needs to be up and running at all times, contact us today. We'd love to help.

How to: Install PHP w/ FPM + Memcached + GD + MySQL on FreeBSD 8

Adrian Singer, November 30, 2011    --    Posted under Programming
Enjoy our step-by-step guide to configuring PHP 5 with FPM, NGinx Web server, Memcached and MySQL 5.1, on FreeBSD 8:

1. Install FreeBSD 7 compatibility and standard packages

make all
make install

-r libevent
-r libtool
-r m4
-r pcre
-r pdftk
-r rsync
-r vim
-r wget

2. Install ProFTPD

make all
make install

3. Install NGinx

Make sure you click to enable 'HTTP_GZIP_STATIC_MODULE', 'HTTP_SSL_MODULE' and 'HTTP_ZIP_MODULE'

make all
make install

echo "nginx_enable=YES" >> /etc/rc.conf
echo "<?php phpinfo(); ?>" >> /usr/local/www/nginx/phpinfo.php

You can always run make config to redo the configuration options

4. Install CURL+LibXML

make all
make install

make all
make install

5. Install MySQL client and server

make all
make install

make all
make install

mv my.cnf /etc/my.cnf

chmod 777
-R mysql:mysql /usr/local/mysql

-R 777 /usr/local/mysql
-R mysql:mysql /usr/local/mysql

6. Install GD

make all
make install

7. Install PHP 5

make all
make install

make all
make install

tar xvfz php-5.2.8.tar.gz

gzip -cd php-5.2.8-fpm-0.5.10.diff.gz | patch -d php-5.2.8 -p1

gzip -cd suhosin-patch-5.2.8- | patch -d php-5.2.8 -p1

cd php
./configure --with-config-file-path=/usr/local/lib/ --enable-pcntl --enable-fastcgi --enable-fpm --enable-calendar --enable-ftp --enable-mbstring --with-mysql --with-curl --with-mcrypt --with-gd --with-iconv --with-jpeg-dir=/usr/lib --with-mysql=/usr/local/mysql --enable-memcache --with-openssl --enable-soap --enable-sockets --with-zlib --enable-zip --enable-bcmath --with-ttf --enable-gd-native-ttf --with-freetype-dir=/usr/local/lib/ --enable-pdo --with-pdo_mysql --enable-suhosin
make all install

mv php-fpm.conf /usr/local/etc/php-fpm.conf

mv nginx.conf /usr/local/etc/nginx/nginx.conf

8. Install Memcached

make all
make install

9. Install HAProxy

make all
make install

10. Start MySQL and NGinx

/usr/local/bin/mysqld_safe &
usr/local/sbin/php-fpm start
/usr/local/etc/rc.d/nginx start


Verify MySQL is working properly:

Attempt connecting to MySQL:

/usr/local/bin/mysql -uroot

Verify NGinx is working properly:

Point your browser to (replacing with the PUBLIC ip address of the server)

Verify PHP is working properly:

Point your browser to (replacing with the PUBLIC ip address of the server).

If you see the PHP info screen, all is well

How to register SSL Certificate with GoDaddy

Dawn Rossi, July 8, 2011    --    Posted under Get Online
This is a follow-up to an old post I wrote back in 2008 about registering SSL certificates with VeriSign

While VeriSign is still the elephant in the room, these days, all modern browsers support certificates from GoDaddy, Thawte and many other cheaper alternatives to VeriSign.

Unless you have a very good reason to use VeriSign and shell out $400, I would recommend using GoDaddy. Their standard SSL will only set you back $50 and best of all - it is usually issued within minutes.

Step 1 - Register a domain

This is a no brainer.

Step 2 - Verify Whois information and make it public

Your domain whois information must match the company name and address you'd like to list on the SSL certificate.

Update your whois information if you need to (login to your SoftwareProjects account and click on the domain, or use your existing registrar interface) and make sure your whois information can be publicly accessed by

If you have private-registration, you MUST turn it off prior to applying for the SSL certificate. You'll be able to turn private-registration back on once the certificate is approved.

Step 3 - Generate private key

Login to your server via Telnet or SSH and run this command:

openssl genrsa -out 2048

Replace with your target domain name.

You'll be asked to choose a password. Pick any password - it is only used throughout the registration process.

Now enter this command:

openssl req -new -key -out

Again replace with your target domain name.

You'll be asked to provide the country, state, company name and domain name. Make sure you use the EXACT same information as what shows for your domain.

The common name is your

Step 4 - Buy Certificate

Visit GoDaddy's SSL certificate page here and select the Standard SSL certificate for 1 year.

Skip all the optional add-ons.

You will be asked to paste the you prepared earlier.

View 3 Comment(s)
« Previous Posts » Next Posts

About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions