Skip to content

Instantly share code, notes, and snippets.

@astockwell
Last active February 4, 2016 05:23
Show Gist options
  • Save astockwell/9984192 to your computer and use it in GitHub Desktop.
Save astockwell/9984192 to your computer and use it in GitHub Desktop.
AddThis implementation (that actually works!) (add your AddThis analytics profile ID!)
<a class="addthis_button_facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>">Facebook</a>
<a class="addthis_button_twitter" target="_blank" href="https://twitter.com/intent/tweet?url=<?php the_permalink(); ?>">Twitter</a>
<a href="" class="addthis_button">Share this</a>
<script type="text/javascript">
var addthis_config = addthis_config || {};
addthis_config.data_track_clickback = false; //tracking codes added to URLs after a share event
addthis_config.data_track_addressbar = false; //tracking codes added to URL in the address bar using JavaScript
addthis_config.ui_click = true; //open share panel on click (not hover)
</script>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-XXXXXXXXXXXXX"></script>
<!-- OR -->
<a href="" class="addthis_button" addthis:ui_click="true" addthis:data_track_clickback="false" addthis:data_track_addressbar="false">Share this</a>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-XXXXXXXXXXXXX"></script>
<!--
Notes:
------
The <a> tag must be "display: block;" and must have something in it (or a graphic will be added inside it) (use a hide-text CSS technique)
Reference for Addthis:
----------------------
Click tracking: http://support.addthis.com/customer/portal/articles/1013558-removing-all-hashtags-anchors-weird-codes-from-your-urls
Open menu on click: http://support.addthis.com/customer/portal/questions/198134-open-on-click-not-hover
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment