Rethink Commerce Blog

Twitter + Analytics = Love

Posted on January 19th, 2009 by

Most of you are already accustomed with URL address shortening services. You know, those websites which make your URLs short and ugly so you can post them on Twitter, Facebook or just send them to a friend. The thing is you never know where these links end up and how much traffic they drive. For me, working in web analytics, not knowing something like this is itching like hell, so I have decided to find a solution to it.

Tackling the problem

What I did is create a special GreaseMonkey script for Firefox (you need to have GreaseMonkey installed), which offers the possibility of adding Google Analytics variables in order to easily track all the users clicking on the short URL you are just about to generate. Here is how the the new homepage will look like after you install the script.


As you see, you have the possibility of adding 3 new fields: Campaign Source, Campaign Medium and Campaign Name. Filling in these fields will allow you to see all the visits generated by this link in Google Analytics. For example, I am going to tweet about this blog post on my twitter account and I will use the following data:

Campaign Source: Twitter
Campaign Medium: social-media
Campaign Name: Twitter-Analytics-Blogpost

If you want to know more about how to customize your links for analytics purposes, has a great post on link tagging for Google Analytics.

Tomorrow, when I’ll get to office, I’ll login to my Google Analytics Account and will be able to see all the visits triggered by the Campaign Twitter-Analytics-Blogpost under Traffic Sources > Campaigns.

The beautiful part now is that in Google Analytics I will be able to segment all the traffic I have generated with this post and see  if  I did a good job in providing the content and experience in order to engage you.

The script works for any of the following shorten URLs websites:

I am just a ninja wannabe analyst, not a Javascript master. So, if you think you can improve my code, please do; if you manage to do something really cool about it, please let me know. I’d really feel proud about it. :)

Of course you already know about my love for Firefox and the great community that supports it. And then it’s Twitter, Facebook, WordPress and the list can go for miles. I am using all of these and they make my work easier and more pleasant, so today is my turn to give something back to the open web.

I’d like to thank Avinash Kaushik for the idea for this script. It was when reading one of his tweets that I got the idea of developing it.

If you would like me to add improvements to the script, make it available even for more ShortenURL services or if I can be of help in any way please tweet me (@cllaudiu) or just leave a comment to this post. Your feedback would really make me feel good about it :).

Last Update: Joost de Valk just posted on his blog a similar method (without GreaseMonkey) that uses the service for tracking shorten URLs.

0.00 avg. rating (0% score) - 0 votes
0.00 avg. rating (0% score) - 0 votes

Claudiu Murariu

Digital Analyst Consultant

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

Comments (8)

  • Twitter + Analytics = Love | says: January 19th, 2009 at 1:39 pm

    […] Twitter + Analytics = Love […]

  • Rajeev Edmonds says: January 19th, 2009 at 3:26 pm

    Great script Claudiu.

    I’m going to use it for tracking selective links on various sites.

  • Performanta Campanii Online de Bannere si Advertising | Claudiu Murariu - Strategie & Analiză Web says: January 25th, 2009 at 6:13 pm

    […] cei interesați și mai mult de trackingul campaniilor online, săptămâna trecută am postat un articol pe blogul Avangate despre cum poți folosi tagurile de Google Analytics pentru a face tracking la linkurile pe care le […]

  • links for 2009-01-26 at DeStructUred Blog says: January 27th, 2009 at 5:02 am

    […] Tracking Twitter and Shorten URLs in Google Analytics | Avangate Blog – Software Business Blog (tags: twitter statistics web url traffic stats tracking webanalytics) […]

  • Liviu Taloi says: February 6th, 2009 at 11:53 am

    Nice work. Can you combine the plugin for wordpress “twitter tools” with your script and maybe with the tracking abilities of this one: ??
    I wandering if this could be possible.. Claudiu?

  • Love For Marketing. | says: March 15th, 2009 at 10:56 am

    […] Tracking Twitter and Shorten URLs in Google Analytics | Avangate Blog – Software Business BlogDo You Love Learning? | Net Marketing For NewbiesNigel Hollis » Blog Archive » Brand leaders: love at first sight?There Is No BlackHat Love In Louisville SMO | Louisville KY MarketingCorporate America/Canada – People Love Blogs, Just Not Yours » e-Storm BlogAsk the Angels » Blog Archive » Everyone Works for Marketing, part I: Love, Hate, and Customer Service Marketing With Love? Why I Love Affiliate Marketing Series – Part 2 | They Call Me WahmmyDoes mobile advertising work without mobile marketing? | We Love Mobile BlogToo much love? « Marketing Donut blog […]

  • Dean says: January 16th, 2010 at 4:09 am

    Thanks for the post! Correct me if I am wrong, all of this is still manual. You would need to jump through a few hoops in order to put this in effect, correct? Once you compress the address from your tool, you then take that and have to tweet it. Are you aware of any completely automated mechanisms to simply write a blog post, say, within WordPress, click the publish button, the permalink gets assigned into an appropriate Google Analytics campaign, the URL is shortened through some URL shortener, and automatically tweeted – thus completely automating the entire process.

    Some of the other posts that I have read related to the Google Analytics / Twitter issues involve using a URL generator within Google, assigning things much like you note into a campaign, generating a URL, then taking that new “Google” URL (which points to the blog post permalink), and then running that through, say,

  • Claudiu says: January 18th, 2010 at 7:32 pm

    Hi Dean,

    Yes, you are right… you still need to do this manually for every link. The advantage of this is that you have full control on the way you generate links.

    If you look for something automatic you can either check the following plugin: It should support the adding of Google Analytics parameters to your blopost. You can also try to hack an existent URL shortener plugin for wordpress to use it just for this.