Twitter tracking with Google Analytics using Twitter-Tools

For the WordPress bloggers that use Twitter Tools I made some modifications in /plugins/twitter-tools/twitter-tools.php at line 186 (line 480 at new version of this plugin, try to look for "$tweet->tw_text"). I inserted some tracking variables for Google Analytics

Making titles a long string without strange chars

$spaces = array(" ", "-", "!", "&", "’", "`", "?", "_");

$escapedtitle = str_replace($spaces, "", $post->post_title);

$link=get_permalink($post_id).’?utm_source=twitter&utm_medium=social-media&utm_campaign=’.$escapedtitle;

Instead of the original line at 187

$tweet->tw_text = sprintf(__($this->tweet_format, ‘twitter-tools’), $post->post_title, get_permalink($post_id));

I put this

$tweet->tw_text = sprintf(__($this->tweet_format, ‘twitter-tools’), $post->post_title, $link);

Reading these days this post written by Claudiu about tracking Twitter with Google Analytics and using for a long time ago Google URL Builder for tracking all my online marketing campaigns, I made this modifications in the plugin I use for updateing my twitters with my blog posts. If you don’t use Twitter Tools and use online services like TinyUrl to shortening your URLs use the script provided by Claudiu on his post.

You’ll find your statistics in GA / trafic sources / campaigns under source=TWITTER and medium=SOCIAL-MEDIA. After that you can track stats for each tweet, looking to campaigns titles = your post title w/o spaces and ohter strange chars. 

Another way to track your links is using this service, TwitClicks.com, which short your URLs but in the same time show you stats.

Keep an eye on your tweets!

Share Button
No tags for this post.

Related posts

2 thoughts on “Twitter tracking with Google Analytics using Twitter-Tools

  1. Pingback: Posts about Twitter Plugins as of February 6, 2009 | The Lessnau Lounge

Leave a Reply

Your email address will not be published. Required fields are marked *