Tracking Code: Social Plug-in Analytics

This reference describes the method that you use for using Analytics on social sharing buttons located on your website pages, such as Facebook "Like" buttons and bookmarks. You do not need to use this method for the Google+ Badge or +1 Button, which automatically send interaction data to your Analytics account. For more information on implementing Social Plug-in Analytics, see the Social Interactions Analytics Guide.

GATC Social Tracking Method

  • _trackSocial(network, socialAction, opt_target, opt_pagePath)

Method Details


    _trackSocial(network, socialAction, opt_target, opt_pagePath)

    Constructs and sends the social tracking call to the Google Analytics Tracking Code. Use this to record clicks on social sharing buttons on your website other than the Google+ Badge or +1 Button, (for which reporting is pre-configured).

    _gaq.push(['_trackSocial', 'facebook', 'like', '']); 


      network (String) The network on which the action occurs (e.g. Facebook, Twitter)
      socialAction (String) The type of action that happens (e.g. Like, Send, Tweet).
      opt_target (String) Optional. The text value that indicates the subject of the action; most typically this is a URL target. If undefined, defaults to document.location.href. For example, if a user clicks the Facebook Like button for a news article, the URL for that news article could be sent as the string. You could also supply any other ID identifying the target, such as an ID from your content management system. As another example, a user could click the Like button next to a blog post, in which case no value need be sent for this parameter because the current document location URL is sent by default.

      Note: If you want to leave this value undefined at the same time you want to supply a value for the next parameter (opt_pagePath), you must specify undefined in your code.

      opt_pagePath (String) Optional. The page (by path, not full URL) from which the action occurred. If undefined, defaults to document.location.pathname plus You will only need to supply a value for this string if you use virtual (or custom) page paths for Analytic reporting purposes. When using this option, use a beginning slash (/) to indicate the page URL. For more information, see "Virtual URLs" in Typical Customizations.