Last active
October 5, 2015 22:27
-
-
Save googleanalyticsresoneo/2887422 to your computer and use it in GitHub Desktop.
AddThis and Google Analytics integration Async Syntax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="ISO-8859-1"?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html> | |
<head> | |
<script type="text/javascript"> | |
// standard GA async code | |
var _gaq = _gaq || []; | |
_gaq.push(['_setAccount', 'UA-XXXXXXX-Y']); | |
_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> | |
</head> | |
<body> | |
<!-- AddThis Button BEGIN --> | |
<p>Only actions on this button get tracked to Google Analytics</p> | |
<p>Tracks only the opening of the third party service, not effective sharing with loopback, completion</p> | |
<a class="addthis_button" href="http://www.addthis.com/bookmark.php?v=250&pubid=ra-xxxxxxxxx"><img src="http://s7.addthis.com/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a> | |
<script type="text/javascript"> | |
// set the options for addthis | |
var addthis_config = addthis_config || {}; | |
_gaq.push(function () { | |
// once ga.js is loaded, bind YOUR tracker with addthis, don't let addthis create a new one | |
var gaPageTracker = _gat._getTrackerByName(); | |
addthis_config.data_ga_tracker = gaPageTracker ; | |
addthis_config.data_ga_social = true; | |
}); | |
</script> | |
<script type="text/javascript" src="http://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-xxxxxxxxx"></script> | |
<!-- AddThis Button END --> | |
<!-- AddThis Button BEGIN --> | |
<p>Actions on these buttons DON'T get tracked to Google Analytics</p> | |
<div class="addthis_toolbox addthis_default_style addthis_32x32_style"> | |
<a class="addthis_button_preferred_1"></a> | |
<a class="addthis_button_preferred_2"></a> | |
<a class="addthis_button_preferred_3"></a> | |
<a class="addthis_button_preferred_4"></a> | |
</div> | |
<script type="text/javascript" src="http://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-xxxxxxxxx"></script> | |
<!-- AddThis Button END --> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment