Tagger: Easier Google Analytics URL Tagging

Written on 16 dec 2010 and tagged tools, Google Analytics

Tagging with campaign variables is a good practice when sharing links to your website. It allows you to track the traffic you receive from that link, so you can do all sorts of awesome analyses. But there’s a problem.

Using custom source and medium in Google Analytics

Or rather, there are two problems with tagging URL’s:

  • Tagging links is too much work: you have to Google for Google’s URL builder tool, figure out what values you want to use for your campaign, and then copy the URL it spits out.
  • Tagged URLs are ugly: It’s not very nice to send someone a link like http://mysite.com/mypage?utm_campaign=x&utm_source=y&utm_medium=z.

So, I wanted an easier way to tag my links — and I created a tiny Sinatra application (source code) to do it. All the cool kids create tiny Sinatra applications to do stuff, right?


My Tagger tool1 looks much the same as Google’s original, but it can take some of the work of entering values by hand off your hands. It let’s you pick a set of predefined values — a template, if you will — and specify only the values that matter.

So, you can use a pretty form to pick “social media” as your medium and “twitter” as your source. All you have to do is specify your campaign title. The point is, you no longer have to remember if you previously tagged your social media campaigns with “social_media”, “social-media” or “socialmedia” as your medium.

Other templates include newsletters and offline campaigns. You can still enter all variables by hand if you want, though.

URL Shortening

When you generate a tagged URL, a tiny Sinatra application will parse your input and merge the generated campaign variables into the URL. It will then return to you the tagged URL and a shorter version, generated using bit.ly.

This helps with sharing, as a http://bit.ly/foobar URL is much nicer to receive. There are two notes to make here:

  1. You really should own your own URL’s. You don’t want to lose all your incoming traffic when bit.ly suddenly goes out of business or whatever. You might want to set up your own custom URL shortener, resulting in something like http://mysite.com/s/foobar.
  2. You should use vanity URL’s — basically a server-side rewrite or redirect from a pretty URL like http://mysite.com/xmas to your actual landing page at http://mysite.com/pages/christmas-sale.html?utm_campaign=christmas-sale&utm_medium=offline&utm_source=radio.

Make it even easier

In order to make sure you never share untagged links, tagging has to be as quick and easy as possible. So here’s an idea to make that happen:

  • Create a simple JSON or XML API for the service, which should be fairly simple.
  • Integrate it in external tools, like a WordPress dashboard widget. This would make it dead easy for authors to tag links.

Oh, so many ideas, so little time… Maybe someone will fork the project on Github and do it?

  1. Tagger is not really a cool name, I know. Sorry.

You cannot leave comments on my site, but you can always tweet questions or comments at me: @avdgaag.