Hey you! Where have you been?

No this is not just a question for someone you haven’t seen for a long time. This tutorial tells you how to see what other websites your visitors have visited. This can be especially usefull when you see which competitors websites someone has visited. You can use this information to emphasise on your unique selling points compared to the visited competitors or to find out which competitor names you should use as a searchterm.

Script in action
You recently visited:

How does it work?
The trick of history detection is looking at the color of visited links. Therefore you need to use a separate color in your stylesheet for visited links. Thanks to Jeremiah Grossman an Robert Cabri for this easy to use script. The script uses javascript and should work in almost all browsers. You need to know the hexadecimal and RGB values of your visited color. The security settings in browsers prevent you from looking at the entire history file, but if you have a link to a visited website on your webpage it will have the a:visited properties attached by it by the browser. Javascript can then look for these properties and communicate them back to for instance Google Analytics or any other javascript command.

The script
Fill in your own a:visited color (make sure it is different from a:link and a:hover). Use this hexadecimal to rgb converter to find out the RGB value for Firefox. Then fill in every URL (each separate webpage) you want the script to check for in the visitor’s browser history.

Just look at my own javascript http://www.vdgraaf.info/js/javascripts.js or the code below:

addEvent( window, ‘load’, stealHistory );
 
var IEVisitedColor = ‘#cd0018′;
var W3CVisitedColor = ‘rgb(205, 0, 24)’;
 
var websites = [
  "http://ajaxian.com/",
  "http://www.dicabrio.com",
  "more of your sites...."
];
 
function stealHistory()
{
  if(document.getElementById(‘site-list’))
  {
    var List = document.getElementById(‘site-list’);
 
    for( var i = 0; i < websites.length; i++ )
    {
      var bRemove = false;
      var ListItem = document.createElement('li');
      var Link = document.createElement( 'a' );
      Link.href = websites[i];
      Link.id = i;
 
      Link.appendChild(document.¶
createTextNode(websites[i]));
      ListItem.appendChild(Link);
      List.appendChild(ListItem);
 
      if( Link.currentStyle )
      {
        var color = Link.currentStyle['color'];
 
        if( color == IEVisitedColor )
        {
          bRemove = true;
        }
      }
      else if( document.defaultView.¶
getComputedStyle( Link, null ) )
      {
        var color = document.defaultView.¶
getComputedStyle( Link, null ).color;
       
        if( color == W3CVisitedColor )
        {
          bRemove = true;
        }
      }
 
      if( bRemove == true )
      {
        List.removeChild(ListItem);
      }
      else
      {
        urchinTracker( '/visited/' + websites[i] );
      }
    }
  }

And then
In Google Analytics you can now find the visited URLs under “Content Optimization” -> “Content Performance” -> “Content Drilldown” under the fake directory “/visited”. Feel free to customize this script to do whatever you like with your visitors history. It can also be used to offer specific content directly. Like “I see you have visited … You probably don’t know that our service is much …”

This script tracks every javascript enabled visitor. Not just the users of MyBlogLog.

Leave a Reply