How to Track Twitter Referrals from a WordPress Blog

Written by Richard Ward

Here at OurChurch.Com we use Google Analytics extensively to track what is trackable. Everything from referral traffic sources to click through rate information on specific keywords can be tracked and easily interpreted in graphical format once Google Analytics is fully integrated into your site

One trackable element that seemed to escape our tracking data was when our links are shared using our Tweet button and capturing event tracking data from those user actions. Questions such as whether or not visitors are sharing links from our blog homepage or the individual post, where to properly place the tweet button to get the most clicks, how much traffic is our site receiving from our posts being shared on Twitter, etc. were yet to be answered.

To solve this problem, we implemented Nicolas Gallagher’s WordPress modification “Custom Tweet Button for WordPress“. The Custom Tweet Button modification consists of adding two php files to your WordPress configuration and making several edits to your theme’s functions.php and styles.css files. The Tweet Button created by this add on is simple HTML and the webmaster has full control over the exact call sent to the Twitter service. Since the webmaster has full control over the call, it is possible to easily embed Google Analytics campaign tracking information.

You will need a API key to use the modification. When we signed up, API key generation was a manual process and took a few days to complete. Once you have your full API key you have everything you need to implement this custom modification to your own WordPress setup.

After you have made the appropriate file modifications and uploaded the files included in the modification package, adding the tweet button is a simple matter of calling the function tweet_button in your desired template file (for an individual post, you will call the function in your single.php file).

Adding your own custom tweet button gives you full control over the HTML/CSS of your Tweet button, saves all of your click/referrer data to your account, speeds up your page loads since there’s no need for javascript or iframes and makes it simple to add in Google Analytics for even more data.

Do you have your own blog? Do you use WordPress? Are you currently tracking your Twitter data in anyway? Share your data tracking experiences in the comments.

About the author

Richard Ward

Richard Ward is a Sr. Web Applications Developer for OurChurch.Com. Richard's professional background is in LAMP style web development. Richard is also a technology enthusiast with a strong interest in emerging technologies. You can reach him at or on Twitter at @OCCRichard.