Lee Willis

Tracking Twitter Traffic Redux

| 2 Comments

I wrote a previous post about how you could hack the excellent Twitter Tools plugin from Alex King to add Google Analytics tracking variables to the URLs posted to twitter when you posted a new blog post.

I submitted the patch upstream, and Alex kindly pointed out that rather than bodging around in his code – you could achieve the same effect with a filter.

So, here it is. Simply download this file and save it in your wp-content/plugins directory. Activate the plugin in your WordPress backend (It will be listed as “Twitter Tools Tagger”) and away you go. Whenever the twitter-tools plugin tweets about one of your blog posts, the URL will be tagged with analytics tracking.

As an added bonus, version 2.0 of Alex’s plugin can also pump your URLs through the http://bit.ly/ URL shortening service so your URLs will be tagged, and shortened.

So, that’s nice.

2 Comments

  1. How would you modify the plugin to include the slug as the utm_campaign variable? I found this snippet that gets the post slug:

    $post_data = get_post($post->ID, ARRAY_A);
    $slug = $post_data[‘post_name’];

    But I’m not sure how I can integrate it into my function. Cheers

    • Hi David,

      To be honest, I’m not sure off the top of my head at what point this function gets called – so not sure what variables are available to grab the post ID from. You’d have to do some digging to check.

Leave a Reply

Required fields are marked *.