Social Interactions - Web Tracking (analytics.js)

This guide describes how to measure social interactions using analytics.js.


Social Interaction Analytics allows you to measure the number of times users click on social buttons embedded in webpages. For example, you might measure a Facebook "Like" or a Twitter "Tweet."

While event tracking measures general user-interactions very well, Social Analytics provides a consistent framework for recording social interactions. This in turn provides a consistent set of reports to compare social network interactions across multiple networks.

Social interactions consist of three types of data:

Value Type Required Description
socialNetwork String Yes The network on which the action occurs (e.g. Facebook, Twitter)
socialAction String Yes The type of action that happens (e.g. Like, Send, Tweet).
socialTarget String Yes Specifies the target of a social interaction. This value is typically a URL but can be any text. (e.g. http://mycoolpage.com)


To send a social interaction, you pass the ga function the send command with the social hit type

ga('send', 'social', 'facebook', 'like', 'http://mycoolpage.com');


  • facebook is the socialNetwork
  • like is the socialAction
  • http://mycoolpage.com is the socialtarget

The send command also accepts an optional field object as the last parameter for any of these commands. The field object is a standard JavaScript object, but defines specific field names and values accepted by analytics.js.

For example, you might want to set the page field for a particular social interaction. You do this using:

ga('send', 'social', 'socialNetwork', 'socialAction', 'socialTarget', {'page': '/my-new-page'});

Finally, all the parameters of the send command have their own field names. So you can send a social interaction by only passing a configuration field object to the send command:

ga('send', {
  'hitType': 'social',
  'socialNetwork': 'facebook',
  'socialAction': 'like',
  'socialTarget': 'http://mycoolpage.com',
  'page': '/my-new-page'

Read the Field Reference document for a complete list of all the fields that can be used in the configuration field object.


Since specific details for integrating Social Analytics varies by social network, the rest of this guide provides general best practices on how to set up measure social interactions. We recommend you check the developer documentation for each network to figure out the network specific implementation.


By default, Google Analytics provides integrated reporting for the +1 Button. This means if you have implemented analytics.js and a +1 Button on the same page, all +1 interactions will be automatically reported as social interactions via each of the trackers on the page. For more information on +1 Analytics, including troubleshooting tips, see About Social Analytics in the Help Center.


According to the Facebook JavaScript SDK, the simplest way to set up and measure a Like button on your page is to use the following code:

<script src="//connect.facebook.net/en_US/all.js#xfbml=1"></script>


To measure social interactions with this button, you subscribe to Facebook's edge.create event and create a callback function to execute the send command:

FB.Event.subscribe('edge.create', function(targetUrl) {
  ga('send', 'social', 'facebook', 'like', targetUrl);

When a user Likes your page, the callback function is executed and receives the URL of the target being liked. The target is then passed as a value to the ga send method and the social interaction is sent to Google Analytics.