AddThis is one of the best services to add share buttons to your website for free. It allows you to pick your buttons, grab a small piece of code, and put it on your website, that’s it!

But while using AddThis buttons on this website, I noticed strange hash codes or random characters added to the URLs in the shares done using the buttons. You may see it yourself by clicking the AddThis tweet button, the tweet window will show the code I’m talking about.

Screenshot demonstrating extra code added in AddThis shares

I’m not using AddThis now, but in this post, I’m sharing how to remove that weird piece of code from your URLs if you’re using AddThis on your site.

Why AddThis adds this extra code to my URLs?

The extra code is actually an identifier string that is added for the URL tracking purposes. AddThis provides two types of URL tracking by default: Click tracking and Address bar tracking. The role of these tracking parameters is to track the traffic sources using the AddThis analytics.

With the click tracking enabled, the link appears something like this in the shares:

http://www.example.com/#.Up9HbkfptnE.twitter

In the Address bar tracking mode, the 11-character identifier is added to the shared URL:

http://www.example.co/#.USvVcVpAQco

Getting rid of weird code in AddThis shares

You can turn off AddThis URL tracking by adding a small bit of JavaScript code in your website. Using the below code in your website will turn off both click and address bar tracking of links:

<script type="text/javascript">
  var addthis_config = addthis_config||{};
  addthis_config.data_track_addressbar = false;
  addthis_config.data_track_clickback = false;
</script>

Remember that you have to put the above code just before the closing head tag (</head>) in your website’s HTML. After saving changes, you will notice no extra hash codes added to your shared links.

Separate code to disable specific tracking

In case you are not wishing to disable both AddThis tracking types for your URLs, below are the separate codes to disable a specific tracking.

Disable Click tracking
<script type="text/javascript">
  var addthis_config = addthis_config||{};
  addthis_config.data_track_clickback = false;
</script>
Disable Address bar tracking
<script type="text/javascript">
  var addthis_config = addthis_config||{};
  addthis_config.data_track_addressbar = false;
</script>