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

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

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