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

Six easy web security tips for non-techies

In the last couple of months, I've seen friends of mine have their email, Twitter and/or Facebook accounts used to send out spam, and I've had a couple of conversations with friends and family about how to increase their security online. This post, as you've probably already guessed, is a package of those conversations to help out those folks that still think of these issues as "computer stuff", when they are simple and necessary steps to living a more secure online life. If you consider yourself a non-techie, read these and incorporate them into your online life. They'll bring you a lot more security and peace of mind. If these are things you already know, I'd love to hear from you in the comments. What things have you done to persuade non-techies to be safer? And what additional tips do you have? The sum: Get a good password When your account is sending spam, change your password immediately Know what websites you're logging into When in doubt, don...