If you’re using Google Analytics and you’re not taking advantage of its built-in campaign tracking, you’re missing out on important insights. Campaign tracking uses URL query strings to determine where your traffic is coming from specifically. URL query strings are the funny “?something=this&somethingelse=that” text that you see on the end of URLs (try a Google search and look in your address bar). By using this tracking method, you can understand your traffic better and learn what’s working and what isn’t. It’s particularly beneficial for people who are promoting their site across several different channels like email, Twitter, and Google Adwords. Here is a little more in-depth description from Google.
The most annoying part about using tracking codes, however, is creating the URL. You need to append at least two (and up to five) query strings to your URL to use this function in Analytics and making this happen while tracking what codes you’re actually using is frustrating enough to make you rethink this whole thing in the first place. Google provides a cute little tool to help you but it’s still a pain in the ass.
Google Docs to the rescue! Using similar code as my simple Google Docs CMS, I created a script that parses a spreadsheet full of tracking codes and turn them into usable URLs that you can then copy and paste. It makes it easy to keep track of the campaigns you have while quickly creating error-free URLs. See the Google Docs UTM appender in action.
Download the UTM URL builder
What you’ll need:
Easy enough… go to docs.google.com and log in. Click the Create New button on the top left and select “Spreadsheet.”


Now, we need to open the PHP file and give it the link to your Google Doc. Open the index.php file as plain text using Notepad (PC) or TextEdit (Apple). When you open the file, you should be able to read the code clearly (even if you can’t quite understand it). You should see “$feedName=” right near the top of the document. Paste the link you copied in the step before in between the tick marks after the equals sign. When you’re finished, you should have some like this:
$feedName = ‘http://spreadsheets.google.com/feeds/cells/tjMfK6oILkthGlM9Vo_8ACQ/od6/public/basic?alt=rss’
If the link is correct, the script should be ready to display the Google Doc. Unless you have a server instance installed locally, you’ll need to upload this script to a public web server. If you have your own website, just upload this file to any public folder. If you’re confused, email your IT department or your tech-savvy niece.
Once the file is uploaded, you’ll want to test it out to make sure everything is working. Go to the file you uploaded (http://[your domain]/[the path to the folder you used]/link-append-util.php) and you should see “UTM coded URLs” at the top. If you see “Invalid feed!” then the link to the Google Doc was not made. Make sure the URL is correct and in between the tick marks after $feedName=.
Once the script is functioning, you’re ready to input your URLs and tracking codes.
The spreadsheet needs to by laid out properly to make sure that the script can read and display the information in the right order. Here are the rules and you can see a sample of a functioning Google Doc here (it’s the one I use to create the example here).
A few things to keep in mind:
Once your codes are loaded, refresh the script and you’ll see them listed nicely in a row. In order for each one:
That’s all I ask!
Please leave comments, questions, and suggestions below. I hope this saves you as much time as it save me!
Also... you should follow me on Twitter here and you should subscribe to my posts via RSS here or email here.
Leave a Reply: