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 you should be clicking the Google +1 button

One of the things that most makes me feel like I'm beating my head against a wall is when I'm trying to convince people to click reaction buttons like the Facebook Like button or Google +1 button on web pages. I think that most people just don't really think to do it when they read something that they like, but they should, because as Avinash Kaushik brilliantly termed it , it's applause.  Now, I kind of get why people shy away from the using the Facebook Like button: because it shows up on your Wall, has a chance to show up in people's stream and now shows up in the ticker. All of those things are great for people trying to promote their content and get more clicks, but it's not so great for those of us just trying to get feedback on what people are liking and if they're actually reading what we're writing. Even if you're not actively embarrassed to have people know that you like it, it just feels a little more intrusive than a lot of people wan...

Why Google+'s Circles doesn't fix anything

One of the biggest advantages of social media-style communication is the ability for your audience to choose itself rather than for you to assume interests and choose the audience yourself, likely leaving out people that would be interested. Anyone who's started a blog knows the surprise in finding that the people who read it religiously are the people you never would have thought would be interested, while many of those people that you thought would read every word never look at it. Likewise with Facebook, where many of the people I interact with are old friends from the past who have turned out to be surprisingly funny and interesting, whereas closer friends are never to be heard from. The flip side of this is email, where every "To" box requires you to decide who your audience is. That's all fine and well when you just need to get through to one person, but when sending information to larger groups, how do you know you're not leaving out the people who...

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 ...