Search and web apps and conversion funnels

The truth about Google Analytics is that it’s not half as helpful as people make it out to be if you are running a subscription based web app. Why? You can’t correlate things like search terms with conversions to paying subscribers. I know you can with trials using their little code snippets, but seriously who cares?! Paying subscribers are what matter.

I wrote an article a while back about tracking conversions for your web app and optimizing your conversion funnel. The following is a technical follow on to that article and describes how we at FreshBooks know which sites – and which search terms – turn traffic into, not just trials, but paying subscribers.

Take it away Jeffrey:

We use cookies set in PHP to track entry pages, referring domains and referring URLs. Cookies are used because their value is stored even if the user leaves the FreshBooks website or if the user closes their browser window.

We set two cookies, the referring URL and the URL used to access the FreshBooks website (entry page). We also set the cookie to expire in 90 days so if they come back at a later date we still have data from the first time they visit us. The code below shows how to do this. It is place at the top of every page on the FreshBooks website

setcookie(“referrer”, $_SERVER['HTTP_REFERER'], time() + 3600 * 24 * 90);
setcookie(“entrypage”, $_SERVER['REQUEST_URI'], time() + 3600 * 24 * 90);

Because this code is run on every page we have to make sure it does not set a new cookie every time a visitor clicks on a different FreshBooks page and we also make sure we don’t overwrite the users cookies if they are visit us before and came back.

if(!$_COOKIE['referrer'] and !$_COOKIE['entrypage'] and eregi(“freshbooks.com”, $_SERVER['HTTP_REFERER']) == false) {
setcookie(“referrer”, $_SERVER['HTTP_REFERER'], time() + 3600 * 24 * 90);
setcookie(“entrypage”, $_SERVER['REQUEST_URI'], time() + 3600 * 24 * 90);
}

Now when a user subscribes it’s as simple as storing these values in a database which can be used for reporting purposes. First we check if the user has cookies set then we use a simple mysql statement to insert these values into the database:

if($_COOKIE['referrer'] or $_COOKIE['entrypage']) {
$referring_url = $_COOKIE['referrer'];
$entry_page = $_COOKIE['entrypage'];
$pieces = explode(“/”, $referring_url);
$referring_domain = $pieces[2];

$query = “insert into tracking (referring_url, entry_page, referring_domain) value (‘$referring_url’, ‘$entry_page’, ‘$referring_domain’);”
$result = mysql_query($query, $connect);
}

So there you have it folks. This is all based on predefined PHP variables – standard stuff really. Anyone and everyone building web apps should be taking advantage of them. End of story.

3 thoughts on “Search and web apps and conversion funnels

  1. Great stuff! Thanks for sharing, one fresh
    idea and you can change the world, keep
    up the great work.

  2. Good article!

    Can your explain in more detail?
    I have a 4 page. And i am place this code on the top of all pages.
    if(!$_COOKIE['referrer'] and !$_COOKIE['entrypage'] and eregi(”freshbooks.com”, $_SERVER['HTTP_REFERER']) == false) {
    setcookie(”referrer”, $_SERVER['HTTP_REFERER'], time() + 3600 * 24 * 90);
    setcookie(”entrypage”, $_SERVER['REQUEST_URI'], time() + 3600 * 24 * 90);
    }

    When i coming on any page from google, the COOKIES not saving

  3. This piece of code is so usefull I can’t even tell you. To be able to quantify which leads came from which keyword searches is such a valuable tool!

    Thanks!
    -Nick Julia

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s