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-7895389-2']); | |
_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> | |
<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; | |
// add the rest of Addthis config below | |
// let's load Addthis' script only once the configuration has been done | |
var adt = document.createElement('script'); | |
adt.type = 'text/javascript'; | |
adt.async = true; | |
adt.src = 'https://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-4fd1eeba189637b6'; | |
var adte = document.getElementsByTagName('script')[0]; | |
adte.parentNode.insertBefore(adt, adte); | |
}); | |
</script> | |
<!-- AddThis Button BEGIN --> | |
<p>Actions on these buttons eventually 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> | |
<!-- AddThis Button END --> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment