Magento – AddThis Extension with Bit.ly Shortener Fix

I have noticed that the Magento extension used for AddThis sharing service does not include the necessary calls for using the Bit.ly URL shortening service with Twitter. Within your AddThis account, you can specifically say that you want to use bit.ly to shorten all links over 40 characters when sharing a page with Twitter. However, if you are using the magento extension (and not just the plain ol’ JS calls to AddThis on your pages), this will not call back and work. Luckily, it’s an easy addition!

To add the API calls back to AddThis for your bit.ly shortening, browse to:

In file: /app/design/frontend/(project)/(theme)/template/addthis/sharingtool/share.phtml

Around line 67, you’ll see:

<script type='text/javascript'>
var addthis_product = 'mag-1.0.1';
var addthis_config 	= {

followed by the PHP code to grab all your Magento-specified settings.

Change to:

<script type='text/javascript'>
var addthis_product = 'mag-1.0.1';
var addthis_share = {
	url_transforms : {shorten: { twitter: 'bitly' }},
		shorteners: {
		bitly: { 
			login: 'Your Bit.ly API Login',
			apiKey: 'Your Bit.ly API Key'
		}
	}
};
var addthis_config 	= {

That’s it! Tested on CE 1.7 and EE 1.12 and 1.13.

Posted in AddThis, Javascript, Magento, Social Media