Twitter tracks what links you click on

September 9, 2009

I don’t really remember when they switched it on, but for a few days now I’ve been noticing Twitter has been tracking what links you click on. When you log onto twitter and click on a link somebody has posted in a tweet, instead of being taken to the location right away, it first takes you to Twitter’s link counter.

For instance, take this tweet by Stephen Fry:

stephenfry Autumnal miniblog

When clicking on the link, you will first be taken to this location:

As you can see, this URL contains a number to identify the tweet that the URL appeared in as well as an ID to identify you as a user. In other words, they might not only count how often a link has been clicked but also who clicks on what.

What I find fascinating (in a bad way) about this is that firstly they never announced this new “feature” and secondly that they’re being secret about it. Because at first sight, the links in tweets seem immaculate. They actually inject this behaviour using JavaScript, so that when you click on a link you’re taken to first. The code in question is loaded from It’s all cramped into the last line, I’ve cleaned it up here for your convenience:

twttr.countClick = function(){
    var A = twttr.createTrackingParameters(this);
    if (A.linkType=="hashtag") {
    else {
    return true};

twttr.resetLink = function(B){
    var A = $(B).attr("original-href");
    if (A) {

twttr.ajaxClickCount = function(A){

twttr.redirectToTracker = function(A,B){
    A.href = "/link_click_count?"+$.param(B)

    var B=$(F);
    var A=function(){
        var K=B.attr("class");
        var I=["hashtag","profile-pic","username","web"];
        for(var J in I){if(K.indexOf(I[J])!==-1){return I[J]}}
    var E=B.closest(".status").find(".meta").children("a").get(0).href.split("/");
    var G=E[E.length-1];
    var H=$('meta[name="session-userid"]');
    var D=H.attr("content")||-1;
    var C=twttr.form_authenticity_token||$('input[name="authenticity_token"]').attr("value");

    var A=$("#content a.tweet-url");"click",twttr.countClick)}

If you’re JavaScript-literate, you’ll see that the last block activates the behaviour by having the functions above called whenever a link in a tweet is clicked.

I’m pretty sure I don’t like my link clicking behaviour logged. Fortunately you can stop it by switching off JavaScript. Or not using the Twitter web interface. Or using a free Open Source alternative such as

5 Responses to “Twitter tracks what links you click on”

  1. […] Twitter tracks what links you click on « philiKON – a journal a few seconds ago from web […]

  2. masklinn Says:

    I saw it pretty early, because it’s completely broken if you surf with disabled cookies (as I do): instead of redirecting you cleanly you get a page saying

    > 403 Forbidden: The server understood the request, but is refusing to fulfill it.

    Another way to bypass the script is to use the right-click options (>Open in new tab) or to drag&drop URLs in the URL bar or a tab bar as those don’t generate click events.

  3. Martin Says:

    As a side effect, the twitter-counter delays loading the clicked-on website by a half to one second. Not much, but it slows down surfing quite noticeable.

    Anyway, ordered NoScript to block scripts on, solved the problem (until they move the js to

  4. thet Says:

    same with google, no surprise.
    sometimes google points to /url which redirects to the desired page, while other times the link to the desired site is directly in the href attribute of the anchor tag.

    there is always some javascript called when clicking on a link.

    i didn’t do a full and deep research about these issues as it seems it’s a bit more complex than i have described here.

Leave a Reply

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

You are commenting using your 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

%d bloggers like this: