Track social interactions with gtag.js

This guide describes how to use gtag.js to track social interactions.


You can use social interaction analytics to track the number of times users click on social buttons embedded in web pages. 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 interactions across multiple networks.

If you're unfamiliar with social interactions in Google Analytics, or you're not sure what values to use for the social network, action, or target, read the article About Social plugins and interactions in the Google Analytics Help Center.


To send a social interaction to Google Analytics, use the event command to send a share event:

gtag('event', 'share', {
  'method': 'social_network',
  'content_id': 'target_of_a_social_interaction',
  'event_action': 'social_action_type'

Social interaction fields

The following table summarizes the social interaction fields:

Field name Data type Required Description
method string yes The network on which the action occurs (e.g. Facebook, Twitter).
event_action string yes The type of action that happens (e.g. Like, Send, Tweet).
content_id string yes The target of a social interaction which is typically a URL (e.g. but can be any text.


The following command sends a social interaction event to Google Analytics indicating that a visitor to had clicked a Tweet button:

gtag('event', 'share', {
  'method': 'Twitter',
  'content_id': '',
  'event_action': 'Tweet'


If you use the official Facebook Like buttons and subscribe to the edge.create event, when a Like action happens, you are notified:

FB.Event.subscribe('edge.create', function(url) {
  gtag('event', 'share', {
    'method': 'facebook',
    'event_action': 'like',
    'content_id': url

For more details, refer to the Facebook JavaScript SDK.