Back to main demo page

Increasing web visitor conversion using session and page counting

Determining your engagement points through web analytics

One of the jobs of today's on-line marketer is to turn all that wonderful visitor traffic into leads (or names if you prefer). We have seen techniques around funnel leakage, micro-conversion points, landing page optimization through nav removal, A/B and multi-variate testing but as a whole these techniques are passive in their approach.

At some point in the visitor's journey with your on-line content, there is a make or break moment where after the nth session or page view where the visitor has consumed enough of your content but will never exchange their contact information for your offers. You can determine the drop-off inflection point through your web analytics in terms of your average page visits after you remove your bounces and visitor who do not complete a goal (form conversion).

Web Analytics - pageviews without goal success

And the same goes for non-bounced returning sessions.

Web Analytics - non-bounced - returning visitors

Turning Web analytics into action

Once we know what levels to set the trigger points at, it is time to put the analytics to work and interrupt the visitor's flow by putting an offer or conversion option in front of them. To do this, we are going to use a series of web cookies to track their engagement.

No Cookie check

In order to gather data, one of the most useful method is through cookies. To make sure the visitor has cookies turn on, the browser needs to be tested if it will store data.

code


<script type="text/javascript" language="Javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" language="Javascript" src="/jquery.cookies.2.2.0.js"></script>
<script type="text/javascript" language="Javascript">
  // test the browser to see if it accepts cookies (via javascript)
  if ( !(jQuery.cookies.test())) {
    // need cookies on, redirect them out of here
    window.location = "http://example.com/no-cookies/";
  }
</script>

Session, page counting

Useful links

Before tabbed browsing, sessions use to be simple, a new browser window mean a whole new session. Now with tabbed and private (Incognito, InPrivate and Private) browsing, the concept of a session has become much more complicated. Still the browser controls its various sessions internal and we can rely on session cookies to detect when a new session has started.

For session count, we can use a session cookie. By setting a unique value into a session cookie, and testing for the presence or absence of the cookie, we can determine if we are in a new or current session. Once we know this the session status, then we can derive all sorts of anonymous information about the visitor including:

MetricPossible uses
New vs Returning visitorVisitor greeting
Session entry (first) pageBehavioural scoring
Session entry query string
  • Marketing program attribution such as affiliates, PPC, etc.
  • lead source
Session referrerCompetition detection
Session Page countproxy for content engagement
Lifetime (absolute) Page countdeeper proxy for content engagement

Attribution and session counting

Useful links

Online attribution can be very useful in trying to sort out how to spend your resources in attracting your visitors to your website but making effective measurements is the other half of the story. I will not delve into web attribution here other than you refer you to Avinash Kaushik's Occam's Razor blog where he has been writing and educating about web analytics for over five years now.

When it comes to adding Marketo into the mix, there are some capabilities at your disposal to help you leverage the attribution. Marketo's javascript munchkin code automatically captures the origin information so you don't have to unless you aren't running munchkin on every page, then you will have to do this work yourself.

Source (First touch) Attribution

Marketo by default via their munchkin code captures Original Referrer, Original Search Engine and Original Query String for first time visitors to provide you with initial lead attribution source. Any of the “Original” type fields can only be inserted into once and never updated. There is also a subtlety to munchkin code where not all of the “Original” parameters are populated at the same time. Basically, if the entry condition satisfies the parameter collection only then the field is populated.

Example:
Say the first visit happens using a paid banner ad, then the Marketo field Original Referrer will be populated with the source (referrer) site's URL but none of the other fields will change. On the second visit, the prospect remembers our ad but uses Google to find the site by typing in a query and is directed via a SERP link, now Original Search Engine and Original Query String will be populated but Original Referrer will NOT be updated.

Within Marketo, there are five (5) Smart List elements you can use for original and session attribution. For original attribution you can use the following:

PPC Attribution

Specifically, for AdWords/PPC attribution, Marketo has an implementation article and sample code to capture the PPC parameters as munchkin does not parse out the PPC parameters automatically. Secondly, if your PPC landing pages do not have a form then you have to preserve the PPC parameters in cookies until you can get the lead to fill out a form. The implication of using non-form landing pages is every form, Marketo or not, needs to have the PPC hidden fields and the PPC attribution javascript to copy the data from cookies to the hidden fields.

Note: Salesforce's integration with AdWords (SFGA) has been depreciated as of the Spring '12 release and support for all users will end Q1 2013. Additionally, SFGA is not available to new customers as of Feb 12 2012

Session counting

In order to interact with the visitors, we need some tracking code that will collect the number of visits and other such details. Below is some javascript code that runs on every page of this website. It has a couple of functions:

Attribution and counting code


<script type="text/javascript" language="Javascript">
/* ----------------------------------
setup domain and prefix counters
---------------------------------- */
var mydomainprefix ='exp';
var mydomain ='example.com';

var new_guid = jQuery.Guid.New();

// setup the counting vars
var guid_session        = jQuery.cookies.get(mydomainprefix + '_session'),
    guid_sessiondate    = jQuery.cookies.get(mydomainprefix + '_sessiondate'),
    guid_pagecount      = isNaN(parseInt(jQuery.cookies.get(mydomainprefix + '_pagecount')))      ? 0 : parseInt(jQuery.cookies.get(mydomainprefix + '_pagecount')),
    guid_sessioncount   = isNaN(parseInt(jQuery.cookies.get(mydomainprefix + '_sessioncount')))   ? 0 : parseInt(jQuery.cookies.get(mydomainprefix + '_sessioncount')),
    guid_totalpagecount = isNaN(parseInt(jQuery.cookies.get(mydomainprefix + '_totalpagecount'))) ? 0 : parseInt(jQuery.cookies.get(mydomainprefix + '_totalpagecount'));

// note: use server time instead of visitor's browser time
<?php if ($_COOKIE['exp_sessiondate']!='') {
  $t1 = strtotime("now") - strtotime($_COOKIE['exp_sessiondate']);
  echo 'var guid_timesincelastvisit = ' . $t1 . ';';
} else {
  echo 'var guid_timesincelastvisit = 0;';
}
?>

// attribution vars
var attr_referrer       = document.referrer,
    attr_refer_domain   = '',
    attr_remote_addr    = '<?php echo $_SERVER['REMOTE_ADDR']; ?>',
<?php if (isset($_SERVER['REMOTE_HOST']) && $_SERVER['REMOTE_HOST'] != null ) { ?>
    attr_remote_host    = '<?php echo $_SERVER['REMOTE_HOST']; ?>';
<?php } else { ?>
    attr_remote_host    = '',
<?php } ?>
    attr_query          = '<?php echo $_SERVER['QUERY_STRING']; ?>',
    attr_firstpage      = window.location.href;

if (attr_referrer != null && attr_referrer != '' ) {
  attr_refer_domain = attr_referrer.substr(attr_referrer.indexOf("\/\/") + 2, attr_referrer.indexOf("\/",8) - attr_referrer.indexOf("\/\/") - 2).toLowerCase();
  if (attr_refer_domain.indexOf(mydomain) != -1 ) {
    // own referrer, don't count it
    attr_refer_domain ='';
  }
}

// test the browser to see if it accepts cookies
if ( !(jQuery.cookies.test())) {
  // need cookies on so redirect them out of here
  window.location = "http://example.com/no-cookies/";
} else {
  guid_totalpagecount++;
  jQuery.cookies.set(mydomainprefix + '_totalpagecount',  guid_totalpagecount.toString(), { domain: mydomain, path: '/', expiresAt: new Date( 2038, 1, 1 ) });
  guid_pagecount++;
  jQuery.cookies.set(mydomainprefix + '_pagecount',  guid_pagecount.toString(), { domain: mydomain, path: '/' });

  // test if the session cookie is set
  if (!guid_session) {
    // new session - create the session and the persistent guid cookie
    guid_session = new_guid;
    jQuery.cookies.set(mydomainprefix + '_session', guid_session, { domain: mydomain, path: '/' })

    // persistent cookies
    guid_sessioncount++;
    jQuery.cookies.set(mydomainprefix + '_sessioncount',  guid_sessioncount.toString(), { domain: mydomain, path: '/', expiresAt: new Date( 2038, 1, 1 ) });

    // we want server time, not client time
    jQuery.cookies.set(mydomainprefix + '_sessiondate', '<?php echo date("Y-m-d H:i:s"); ?>', { domain: mydomain, path: '/', expiresAt: new Date( 2038, 1, 1 ) });
    jQuery.cookies.set(mydomainprefix + '_refer', attr_referrer, { domain: mydomain, path: '/', expiresAt: new Date( 2038, 1, 1 ) });
    jQuery.cookies.set(mydomainprefix + '_referdomain', attr_refer_domain, { domain: mydomain, path: '/', expiresAt: new Date( 2038, 1, 1 ) });
    jQuery.cookies.set(mydomainprefix + '_firstpage', attr_firstpage, { domain: mydomain, path: '/', expiresAt: new Date( 2038, 1, 1 ) });
    if (!attr_query) {
      jQuery.cookies.set(mydomainprefix + '_query', attr_query, { domain: mydomain, path: '/', expiresAt: new Date( 2038, 1, 1 ) });
    }
  }
}

Interrupting the visitor's flow

Now that we have some data on how many pages and how many sessions the visitor has made to our site, you can choose when to interrupt there flow and present them with an offer that will entice them to convert by filling in a form. You could redirect the on to page containing a form but in this day and age my preference is to use a lightbox type method.

Using the web analytic data at the vary beginning of this article you have a good guess as to when you interrupt your visitor. In this specific case I would setup the lightbox to fire on either two conditions:

Below is a code sample to fire a lightbox (fancybox in this case) interrupting the visitor.

 

Interruption code and lightbox


<!-- fancybox inline div -->
<div id="inline" style="display:none;width:500px;"></div>
<script type="text/javascript" language="Javascript">
$jQ(document).ready(function($){

  // allow in-domain javascript access
  // see http://www.nczonline.net/blog/2009/09/15/iframes-onload-and-documentdomain/
  document.domain='hollebone.ca';


  $('#inline').fancybox({
    'titlePosition' : 'inside',
    'width'         : '75%',
    'height'        : '75%',
    'autoScale'     : false,
    'transitionIn'  : 'elastic',
    'transitionOut' : 'fade',
    'type'          : 'iframe'
  });

  // set your interruption parameters here
  if ( 
   (parseInt($.cookies.get(mydomainprefix + '_sessioncount')) >= 2) || (parseInt($.cookies.get(mydomainprefix + '_pagecount')) >= 3) 
   || (parseInt($.cookies.get(mydomainprefix + '_totalpagecount')) >= 5) ) {
    $.fancybox(... some fancybox code...);
  }
});
</script>

Demo

If you have just arrive on this page, then you will see very little happening, but if you close your browser and return OR view 2 more pages then return to this page, I use this technique to show you how it could work. In the case of Marketo, the fancybox can be setup to use an iframe very easily so you can insert your offer.

Use the button below to force the lightbox to show



  • Back to main demo page