Detect which sites a web user visits


Aza Raskin’s SocialHistory Javascript library allows you to do something incredibly cool: detect which sites your web users have visited on a per-user basis. The javascript runtime isn’t supposed to be privy to the information in a user’s browser history, but there’s an information backchannel common to all major browsers which allows you to effectively interrogate the browsing history and determine if a particular URL has been visited before.

It works by creating an anchor link to the site in question and applying a CSS style to the link, specifying a different display property for “a:visited”. By reading the computed style back from the anchor element, you can then determine the property’s value, and consequently if the user had visited the URL or not.

This could probably be used for a number of devious purposes, but Aza’s concept for the SocialHistory library is actually really useful. By querying the default URLs that belong to all the major social network sites, you can figure out which sites a particular user visits and custom tailor any social badges that you display. If they use, you show a link. If they visit Digg, you show the Digg button. It’s an awesome feature made possible by a pretty freaky security leak.

Now, it’s not perfect. It requires that you query the exact URLs that a user may have visited. You can’t figure out everywhere they’ve been, how frequently, or in what order, only whether a particular URL that you know about has been visited before. On the other hand, it’s a pretty useful tool considering you aren’t even supposed to be able to do this.

How to Detect the Social Sites Your Visitors Use

Discuss this article with the rest of the community on our Discord server!