Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eduardocereto/2887567 to your computer and use it in GitHub Desktop.
Save eduardocereto/2887567 to your computer and use it in GitHub Desktop.
AddThis and Google Analytics integration
<script type="text/javascript">
// standard GA async code
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script type="text/javascript">
// set the options for addthis
var addthis_config = addthis_config || {};
addthis_config.data_track_clickback = true; // or your own options
addthis_config.data_ga_tracker = null; // unbind AddThis and GA
_gaq.push(function () {
// once ga.js is loaded, bind YOUR tracker with addthis, don't let addthis create a new one
addthis_config.data_ga_tracker = _gat._getTrackerByName();
addthis_config.data_ga_social = true;
});
</script>
<!-- where you insert the button , put your pusblisher ID-->
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=XXXXXXXXXXXXXXX"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment