Our Custom AddThis Code to use Bitly, Custom Title and Disable Cookies

14th June, 2012 in Technical 1 Comment

There are many options and configurations the AddThis code could have for your setup. We needed the following settings:

  • Twitter username, to offer the option to people to follow AmityWeb when they Tweet our pages
  • Bitly to shorten any URLs, when using Twitter
  • Disable AddThis cookies for the EU Cookie Law
  • Custom Title setup for Twitter (page Title, then the URL link)

Here's our code...

<div class="addthis_toolbox addthis_default_style">
    <a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
    <a class="addthis_button_tweet" tw:via="TWITTER_USERNAME"></a>
    <a class="addthis_button_google_plusone" g:plusone:size="medium"></a>
    <a class="addthis_counter addthis_pill_style"></a>
</div>
<script type="text/javascript">
    var addthis_config = {data_use_cookies:false}
    var addthis_share = {
        url_transforms: {
             shorten: {
                 twitter: 'bitly'
             },
         },
         shorteners: {
             bitly: {
                  login: 'BITLY_USERNAME',
                  apiKey: 'BITLY_KEY'
             }
         },
         templates : {
         twitter : "{{title}} {{url}}"
    }
}
</script>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ADD_THIS_USERNAME"></script>

If you want a custom image to show on the post (e.g. on the Facebook page) then you should put this in the HEAD section of the page:

<link rel="image_src" href="path-to-image.jpg" />
Comments
Picture of Jamie Blacker

Jamie Blacker 18th June, 2012 at 14:38 pm

I've just had to secure a page with an addthis plugin - it's surprisingly simple to do!

Just change the last line to reference: src="https://s7.addthis.com....

An important thing to note is that the tweet button doesn't currently support SSL so this will be blocked and depending on the browser might throw a popup at you.

Leave a Reply

Recent