Last updated 17 January 2014. Created on 30 March 2009.
Edited by matglas86, cedewey, junedkazi, HongPong. Log in to edit this page.

The AddThis module provides Drupal integration to addthis.com link sharing service.

Description from addthis.com:

The AddThis button spreads your content across the Web by making it easier for your visitors to bookmark and share it with other people, again... and again... and again. This simple yet powerful button is very easy to install and provides valuable Analytics about the bookmarking and sharing activity of your users. AddThis helps your visitors create a buzz for your site and increase its popularity and ranking.

AddThis is already on hundreds of thousands of websites including SAP, TIME Magazine, Oracle, Freewebs, Entertainment Weekly, Topix, Lonely Planet, MapQuest, MySpace, PGA Tour, Tower Records, Squidoo, Zappos, Funny or Die, FOX, ABC, CBS, Glamour, PostSecret, WebMD, American Idol, and ReadWriteWeb, just to name a few. Each month our button is displayed 20 billion times.

Requirements

None.

Installation

Normal Drupal 6 module installation, see http://drupal.org/node/70151 for further information on how to install modules.

See also: Drupal 7 installation & configuration instructions.

For link sharing statistics registration at http://addthis.com/ is required, but the module will work even without registration.

Configuration

There are two ways of using the Drupal 6 module:

  1. Display AddThis button in node links.
    • Go to Administer / Site configuration / User Interface / AddThis.
    • Check Display on node pages.
    • Optionally check Display in node teasers.
    • If you want to limit AddThis visibility by content type go to Administer / Content management / Content types and choose a content type. Visibility can be set for each content type under Workflow settings.
  2. Use AddThis as a block.
    • Go to Site building / Blocks and make AddThis button block visible.

Customization

You have a number of options available at Administer / Site configuration / Addthis under Button image settings
and Widget settings. Image settings control the button image and widget controls the drop down and window that is opened when user clicks on a link sharing service. More information on how to customize your AddThis button can be found at http://addthis.com/help/customize/custom-button/

If configuration options are not flexible enough for you it is also possible to override theme_addthis_button in your own theme.

Ajax

If you use ajax features like in views, buttons may not appear because the content is loaded with ajax. The following code fixes that.

Code for D7:
This should be fixed starting with version 7.x-4.0-alpha3.

Code for D6:

Drupal.behaviors.addThisAJAX = function(context) {
  var script = 'http://s7.addthis.com/js/250/addthis_widget.js#domready=1';
  if (window.addthis){
    window.addthis = null;
  }
  $.getScript( script );
};

Roadmap

Future development of this module will include at least RSS support. CCK and Views integration may be included in future releases.

Drupal 5.x version will no longer get any new features.
Drupal 7.x has been a complete rewrite of the module into version 4.x. There are now alpha release that are ready to be tested out.

Contact

Current maintainers:

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

yakker’s picture

First - I love that you've got this into Drupal - such a central functionality. Our (my company's) thanks!
:)

Are there any plans to incorporate the option to display Addthis via Link Decoration as outlined at Addthis.com: http://www.addthis.com/help/api-spec (at the bottom)?
We like big juicy individual service buttons instead of the compact "share" catch-all button. Originally I coded them directly into the tpl files, but that prevents us from administering addthis from the drupal admin interface.

So today I managed to hook into theme_addthis_button() in template PHP to override the current pop-up setting so that it displays a collection of anchors decorated with class declarations (according to addthis_options in the variables table) instead of the generic "share" button. It should be live in a couple of weeks, but it looks exactly like the big button displays we currently have up (which I coded into the tpl. files) at http://www.opusframing.com/blog/artists-lets-change-world (near the bottom of the article). Kudos to jwloh, the source of our great social buttons! (http://jwloh.deviantart.com/art/Social-me-90694011)

So we can now control which big juicy buttons show up, which nodes the addthis buttons show up on, etc, via the admin interface, all thanks to your module and template.php. But I find I want to provide options for button size, custom image path overrides, etc (the big buttons dominate on teasers, for example), and the prospect of hijacking the current variables for size and height (again from template.php) feels a bit hacky. I realize this is all design-centric, but I thought I'd ask.
;)

Thanks again for making this functionality so easy for us to implement.
Chris

In case anyone is interested, what I put into my template.php is below (theme name is "opus"). I'm a fly-by-the-seat-of-my-pants coder (no training), so forgive me if it's clunky.
You have to have your drop-down enabled for the big buttons to come up (which is an arbitrary choice on my part).

<?php
function opus_addthis_button($node, $teaser) {
  if (variable_get('addthis_dropdown_disabled', '0')) {
    return ( sprintf('
      <a href="http://www.addthis.com/bookmark.php"
        onclick="addthis_url   = location.href; addthis_title = document.title; return addthis_click(this);">
      <img src="%s" width="%d" height="%d" %s /></a>
      ',
      $_SERVER['HTTPS'] == 'on' ? addslashes(variable_get('addthis_image_secure', 'https://secure.addthis.com/button1-share.gif')) : addslashes(variable_get('addthis_image', 'http://s9.addthis.com/button1-share.gif')),
      addslashes(variable_get('addthis_image_width', '125')),
      addslashes(variable_get('addthis_image_height', '16')),
      addslashes(variable_get('addthis_image_attributes', 'alt=""'))
    ));
  }
  else { //customized code to display big add this buttons via text decoration
	$options=explode(',',variable_get('addthis_options','twitter,facebook,myspace,digg,linkedin,delicious,email,expanded'));
	foreach($options as &$service){
		$service = '<a class="addthis_button_' .$service . '"><img src="'.base_path().'sites/default/themes/opus/images/socialme/' . $service . '.png" width="60" height="60" alt="' . $serivice . '"/></a>';	
	}
	return (sprintf('
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox">
<h3 class="title">Share this!</h3>
<div class="custom_images">
%s
</div>
</div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js?pub=opusmarketing"></script>
<!-- AddThis Button END -->
	',
	implode("\n",$options)
	));
  } // end custom code
}
?>
vesapalmu’s picture

Sorry, I missed your comment in here. Please use the issue queue for feature requests, they will get more attention that way.

We are currently working with D7 port of the module and next things on our roadmap are addthis API 2.0 conversion which will bring a lot of new feature to the module. Before we move to the new API we are stuck with current functionaltity. Any help is always welcome. :-)

Maciej Lukianski’s picture

Awsome! Thanks for that! Saved me quite a lot of time.

I corrected a small typo and made the code more general (works on my 7.x-2.1-beta1).
The code below:
- uses actual users AddThis username input in the AddThis settings form
- looks for icons in the "path_to_current_theme/images/addthis" folder.
- does not define icon dimensions. themes can provide their own via css if they want to.

function YOUR_THEME_NAME_addthis_button($variables) {
$build_mode = $variables['build_mode'];
  $https = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on';
  if (variable_get('addthis_dropdown_disabled', '0')) {
    return ( sprintf('
      
      Only local images are allowed.
      ',
      $https ? addslashes(variable_get('addthis_image_secure', 'https://secure.addthis.com/button1-share.gif')) : addslashes(variable_get('addthis_image', 'http://s9.addthis.com/button1-share.gif')),
      addslashes(variable_get('addthis_image_width', '125')),
      addslashes(variable_get('addthis_image_height', '16')),
      addslashes(variable_get('addthis_image_attributes', 'alt=""'))
    ));
  }
  else {//customized code to display big add this buttons via text decoration
    $options=explode(',',variable_get('addthis_options','expanded'));
    foreach($options as &$service){
        $service = trim($service);
        $service = 'Only local images are allowed.';
    }
    return (sprintf('
      
      

Share this!

%s
', implode("\n",$options), variable_get('addthis_username', '') )); } // end custom code }
ttamniwdoog’s picture

Don't forget to set your permissions!
After you enable the module, go and set the permissions.
Admin->User->Permissions

druser01’s picture

Hi folks,
I have been trying to find the most rated/liked/tweeted articles; I am using the ADD THIS module.
Can some one point out as to what parameters/methods of this API, I can be using to solve my issue.

Let me take an example to better explain what I am trying to solve.
Example: If a node is +8 facebook likes, I want to be able to store the NID and its related 'like count' in my table.

aamin’s picture

Hi I installed the addthis module and entered the username (email address?) to track sharing stats but it is showing no analytics data in my addthis account.

Is there any additional configuration required to track sharing data.

Thanks

Stephen Ollman’s picture

Spent way too long trying to figure this out before stumbling across this. Why is there no link to this on the main page of above?

http://drupal.org/node/1309922

Certified Drupal Site Builder
OPC IT
Web Application and Development Services