Skip to main content

Posts

Showing posts with the label AddThis

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