Yourls Google Analytics Link Tagging

In my last post, I wrote about the benefits of using YOURLS, a self-hosted link-shortening service. I’m finding that YOURLS is great, but it’s not perfect. Some of the issues I have experience are part of what you get using most URL shortener services.

Some of the downsides of using link shorteners are:

  1. Google Analytics doesn’t always capture the original referrer (and I have no clue how they do the rest of the time!).
  2. When generating links using the bookmarklet (or in this case, also the Yourls installation), there’s no easy way to add campaign, source, medium, content, and term tags for Google Analytics to track.
  3. Yourls doesn’t allow query strings on URLs by default, making overriding existing campaign tags difficult/impossible. For example: http://katz.si/t?utm_source=2300

I’m not the only one who wanted these things, so I’ve created a plugin that adds Google Analytics tracking to Yourls. It’s very cool.

Google Analytics Yourls plugin

Download Google Analytics for YOURLS from Github

The plugin features include:

Define default tracking tags
You can define a set of default tags that are added to any link that gets shortened.

  • utm_source
  • utm_medium
  • utm_name
  • utm_term
  • utm_content

Override existing tags - you can choose to have your tags replace tags in the long URL that’s being shortened…or not.

Tagging options added directly to the URL form – the best feature in my opinion, you now have an interface to easily add tracking right from the link shortener.Add URL tagging options

Add query strings to the shortened URL to override or add any tracking tags. This feature has support for abbreviations, too.

If you want to see this in action, check out the links below.

Plugin Installation

To install, follow these steps:

  1. Download the file (updated to correct Github link)
  2. Upload the google-analytics folder into your users > plugins directory
  3. Go to your YOURLS plugins page
  4. Hover over Google Analytics, click “Activate”
  5. Configure the plugin settings by clicking the Google Analytics link in the menu
This entry was posted in Plugins, Web Development and tagged , , , , , , . Bookmark the permalink.
  • Bobass

    your a spammer. Did you put the malicious script in my ftp? I have way to many LD backlinks on my site from THIS SITE!!
    jerkoff.

    • http://www.seodenver.com Zack Katz

      This script creates no backlinks.

      • http://www.m3mmerlingurgaon.com/ M3M Merlin

        M3M Merlin – M3M launching its new project M3M Merlin in sector 67 on 14 Acres Land area, This Project comprising of a spacious bedroom apartments.

  • Arne

    I couldn’t get the ZIP to download. And I would like to know whether there is any truth on that claim of this creating backlinks to this site.

    Thanks.

  • Arne

    I couldn’t get the ZIP to download. And I would like to know whether there is any truth on that claim of this creating backlinks to this site.

    Thanks.

  • iammatthew

    Has anyone implemented this plugin yet?

  • Jaipur Web World

    I found so many entertaining stuff in your blog,especially on this post. Keep up the good work.
    Jaipur Web World

  • Jeremy

    Amazing.  Thanks.  I made 2 plugins that use the geoipcity and geoipregion to plot hits on city and state levels, but I haven’t released to public yet.   They were much less complicated then your plugin here.  Thanks for sharing!

    • Mark Shreaves

      Hi Jeremy,

         Could you post links to your plugins, I have been trying but unsuccessful. Could really use them for my business.

      Thanks

        Mark

  • http://twitter.com/mr_mark_e Mark Ellingson

    I just started using YOURLS on my short domain name.  Thanks for creating such an easy way for me to add GA campaign info to all my shortened URLS.  This is a great plug in. 

    At first I thought it was going to add the campaign info to the end of my shortened URL based on the examples you listed above, which I didn’t want.  But after trying it out, I found out it did what I want.

    It allows you to place a Long URL and then add GA campaign info to the Long URL prior to shortening it so that your short URL hides it.  I don’t want people to see the campaign info when I post the shortened URL.

    Terrific Job!

    • http://www.seodenver.com Zack Katz

      Thanks, I’m glad you like it!

  • http://www.itconsultancyservices.com/ IT Consulting Services

    A good and informative post. i am grateful to be here. thanks hope to read more from you.

  • lpto

    So how do I add my google account identifier to this?

    • http://www.seodenver.com Zack Katz

      Why would you need to do this?

      • lpto

        Well it should be a google analytics plugin? :P Shouldn’t you need someway of tracking to one’s account then? :P

        • mactac

          So, as far as I can tell, this plugin is useless unless we can add our google identifyer code. how do we do this?

  • mglhm

    This plugin doesn’t seem to work with version 1.6 of YOURLS.

    I found a problem with jQuery live() when toggle the input fields.

    But I still can’t get the data in the fields to be added to the URL. Any suggestions?

    • Jo

      Not working with version 1.6 (polyglot) either

  • Pingback: Create QR Codes With URL Tracking For Free | Mobile News and Tools

  • Djones

    Love the plugin for Yourls!! Great work, but I can not get any stats from google without my google identiifier code. Can you please help us with this? Thanks.

  • Mikey

    We are creating a series of QR codes for a client to track/compare various POS effectiveness. However the code points to a Facebook share, not to the landing page (a simple way for mobile frictionless sharing). I’m not sure this is accomplished with your plug in as it appears to add tracking info to long URL, so you can see campaigns when using the analytics of that domain. I want to plug a single shortened URL into Google’s tracker tool and create separate QR codes (the URL never visible to the user). So I need to track analytics of my short URL domain. Can this be hacked for that or does anyone have an idea. There seem to be a lot smarter people than me on this blog. Thanks!