Skip to main content

How to add Google Analytics campaign code to every AddThis share

I took a little time to browse through the AddThis documentation to see if there was any feature I was missing, and it turns out there was something that I had just been wondering about: adding in Google Analytics code to the end of the URL when someone uses AddThis to share a page on your site.

There's documentation on the AddThis site for adding URL parameters, but here's how I modified it to incorporate the Analytics code. In the AddThis code where you call javascript that powers the widget (s7.addthis.com/js/250/addthis_widget.js), add this in:
<script type="text/javascript">
var addthis_share = 
{ url_transforms : 
{ add: { 
     utm_campaign: 'AddThis', 
     utm_source: '{{code}}', 
     utm_medium: 'share' } } }
<script>
The {{code}} will add in the service that was used to share (ie "delicious", "googlereader", etc) in a single word and in all lowercase letters. You're just adding in the standard Google Analytics variables in place of the "name" and "favorite number" in the example. Of course, you could add in whatever parameters and values you want, but this works really well for GA, meaning you can now track traffic that comes from links shared through AddThis and create a custom segment for that campaign, meaning you can track just how far those AddThis links are reaching. It should also be noted that you can put all AddThis javascript in the head so that it doesn't have to load more than once. See the "Optimize AddThis Script" secition at the bottom of this page.

Comments

Popular posts from this blog

Why are we still judging work done by time spent?

Every morning, when I fill in the hours on my work's electronic timesheet, I'm struck by how odd it is that we're still judging our work by the time spent on it. It's odd because it's old-fashioned. In the paper and phone world, you could really only do work when you were at work. But we do work all the time now. I check my email when I first wake up. Does that mean I start my day at 6:30 am? Should that be reflected on my timesheet? How about when I respond to an email or check Basecamp when I'm on the bus? Does my work day start then? How about when I look at Google Analytics at night or think about email newsletters when I'm in the shower (which I'm somewhat ashamed to admit I did this morning)? On the other side, if someone finishes the work that they're meant to do, why should they feel like they need to stay at work until 5:00, just because that's the official time of the work day? I don't think anyone would argue that time spent ...

Some scattered thoughts on the money of digital music

If you haven't already read Digital Audio Insider's interview with Camper Van Beethoven's Jonathan Segal ¹, it's a must read for anyone with even a slight interest in digital music and the money of the industry. Segal has tons of thoughts on just about every aspect of digital music, but best of all, he brings in these thoughts as someone whose initial music industry experience was in the days of purely-physical media, when "pirating" meant copying something onto a blank tape. My main takeway is general and obvious but an important reminder: we are in a transition time for music, and what it will become is anyone's guess. I think Segal's take on merchandise and live performances taking the place as artist's primary source of income as "asinine" is too harsh to be true, but I do think that we're in such a state of transition that any shot at predicting artistic income in the future is completely in the dark. Such predictions are really ...

Sentiment Measurement Beyond Metrics

You know, headlines like that one really put me on the fence, balancing between "Ooh! Metrics!" and "Wow, no wonder people think it's boring and geeky." ANYWAY...today I'm definitely in the former camp, in the sense that it's exciting because it's a philosophical puzzle: how can you solve a problem that can never really be solved? Yesterday, I commented on Avinash Kaushik's post where he asked, "If you were to measure the success of a company’s social media efforts how would you do it?" My answer: For social media, the obvious metrics still hold: referrals and conversions from referrals. But being from a nonprofit background, where the higher-ups are often skeptical of social media, the real metrics are the words. There’s nothing more valuable than the tweet that says "I love that {your org} is on Twitter" or the time you respond to a comment on Facebook addressing a wide concern about your organization or when you comment ...