Support

Google Analytics Integration



What is it?

AddThis includes a suite of powerful analytics features. However, if you already employ Google Analytics for your site or blog, you might want to have all of your analytics in one place.

Integrating AddThis share data into your existing Google Analytics reports is easy, and lets you view AddThis shares as custom events in your Google Analytics dashboard.



How does it work?

Google Analytics is offered in two flavors: synchronous and asynchronous. Asynchronous tracking is Google's newer, preferred methodology. (If you're using the older form and interested in upgrading, see the migration guide. You can use either with AddThis.)

You must already have a Google Analytics account to integrate AddThis with Google Analytics.

For more information about installing and configuring Google Analytics for the first time, please refer to Tracking sites with Google Analytics.

Configuring AddThis for Google Analytics

Once Google analytics is installed on your pages, you can send AddThis shares to your Google Analytics reports as custom events in the category addthis by adding the following configuration lines to your existing AddThis code. You'll need your GA property ID (generally a serial number of the form UA-xxxxxx-x).

<script type="text/javascript">
      var addthis_config = {
         data_ga_property: 'UA-123456-1'
      }; 
</script>

A few important notes:

  • this configuration code must be contained in a <script> tag
  • your data will not begin to show up in Google Analytics until this configuration code is added to your AddThis sharing code
 
Custom Sharing Event Naming Convention

Once you have installed the code as outlined above, you will begin to see custom events show up in your Google Analytics dashboard. These events will be named:

  • AddThis > {service code} (ex: AddThis > facebook)

Please refer to the AddThis Service Directory for a complete list of services and service codes.

To receive social interaction events instead, see below.

 

Social Tracking

If you're using the latest version of GA, you can take advantage of Google's new social interaction analytics. You don't even have to write _trackSocial hooks. Just opt in with data_ga_social:

<script type="text/javascript">
      var addthis_config = {
         data_ga_property: 'UA-123456-1',
         data_ga_social : true
      }; 
</script>

When using the modern social methodology, we track the network (e.g. "facebook"), the social action (e.g. "share"), and the target (e.g., http://example.com/a/cool/blog).

 

Example Code

Synchronous Method

Here is some example AddThis sharing code with synchronous Google Analytics tracking enabled. Note that the addthis_config object must be included after your Google Analytics include.

<!-- Google Analytics BEGIN -->
<script type="text/javascript">
   var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
   document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>

<script type="text/javascript">
   try{
      var pageTracker = _gat._getTracker("UA-xxxxxx-x");
      pageTracker._trackPageview();
   } catch(err) {}
</script>
<!-- Google Analytics END -->



<!-- AddThis Button BEGIN -->
<a class="addthis_button" href="http://addthis.com/bookmark.php?v=250">
   <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">
   var addthis_config = {
      data_ga_property: 'UA-xxxxxx-x',
      data_ga_social: true
   };
</script>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js"></script>
<!-- AddThis Button END -->
 
Asynchronous Method

Here is some example AddThis sharing code with asynchronous Google Analytics tracking enabled.

<!-- Google Analytics BEGIN -->
<script type="text/javascript">
     var _gaq = _gaq || [];
     _gaq.push(['_setAccount', 'UA-xxxxxxx-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>
<!-- Google Analytics END -->


<!-- AddThis Button BEGIN -->
<a class="addthis_button" href="http://addthis.com/bookmark.php?v=250">
   <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">
   var addthis_config = {
      data_ga_property: 'UA-xxxxxx-x',
      data_ga_social: true
   };
</script>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js"></script>
<!-- AddThis Button END -->
Last Updated: Oct 25, 2013 04:43PM EDT
help@addthis.com
http://assets02.desk.com/
false
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete