Tracking Social Events

Thanks to Tristan at for compiling this list.

How do I track Facebook events?

The Facebook social plugins emit a number of events, most importantly the edge.create event. This is triggered when a user clicks a Like button on your page. If you are using the Facebook JavaScript SDK (rather than a plugin that inserts an iFrame),you can use the following snippet:

<script type="text/javascript">
  FB.Event.subscribe('edge.create', function(response) {
    _kmq.push(['record', 'Facebook like']);

You should paste this code below wherever you include the button.

Facebook’s Developers portal has more up-to-date examples of how best to use their API:

Other events are documented here:

How do I track Twitter events?

Tracking Twitter events is very similar to Facebook tracking. Include the following snippet just below any Twitter follow code:

<script type="text/javascript">'follow', function(event) {
    _kmq.push(['record', 'Twitter follow']);

If you want to track tweets, use this:

<script type="text/javascript">'tweet', function(event) {
    _kmq.push(['record', 'Tweeted']);

A full list of events you can track is in the Twitter dev docs:

How do I track Google +1 (plusone)?

It’s easiest to add the tracking when you create your button:

Click on “Advanced Options” and enter “plusone_vote” into the “JS Callback Function” field.

Below the +1 code, include the following snippet:

<script type="text/javascript">
  function plusone_vote( obj ) {
    _kmq.push(['record', 'Plus 1 vote']);

How do I track LinkedIn shares?

This currently requires an undocumented feature, so keep in mind that this might change in the future.

Start by creating your button on the LinkedIn dev pages Inside the “IN/Share” tag section you need to add the data-onSuccess callback function. Here’s an example:

<script src=""
<script type="IN/Share" data-url=""
  data-counter="right" data-onSuccess="linkedin_share"></script>
<script type="text/javascript">
function linkedin_share() {
  _kmq.push(['record', 'Shared on LinkedIn']);
Is anything on this page unclear? Suggest edits on Github!