Google Analytics Integration (Public Beta)

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 let's you view AddThis shares as custom events in your Google Analytics dashboard.

This feature is currently in Public Beta. Please be sure to post in the Forum if you have questions or comments. Thank you for your feedback.

How Does It Work?

Install Google Analytics Tracking

First, you must already have a Google Analytics account, and have installed Google Analytics tracking in your pages. The generic tracking code snippet consists of two parts: a script tag that references the ga.js tracking code, and another script that executes the tracking code:

<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>

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

Installing AddThis GA Configuration Code

Next, 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 code to your existing AddThis sharing code:

addthis_config = {
   data_ga_tracker: pageTracker
}

A few important notes:

  • this configuration code must be contained in a <script> tag
  • if you use a non-standard name for your tracker object (“pageTracker” in the code above), you will need to pass that name instead
  • the AddThis configuration cannot be referenced on your page until after the pageTracker object is instantiated in your Google code
  • 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)

For a list of all currently supported AddThis services and service codes, please refer to the AddThis Menu API documentation.

Example Code

Here is some example AddThis sharing code with 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_tracker: pageTracker
   };
</script>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js"></script>
<!-- AddThis Button END -->



Back to Top