Archive - October 14, 2011

1
Tracking like button click events

Tracking like button click events

Sometimes, you want to track certain Facebook interactions within your internal analytic tools. Below is code to detect like, unlike, and send message clicks for the Facebook Like Button social plugin. This logs to Google Analytics. Just add the following event subscriptions between some Javascript tags after the Facebook JS SDK has been loaded. “response” is the URL that was liked or sent. Adjust what happens for each event, as desired.

       FB.Event.subscribe('edge.create', function (response) {
            _gaq.push(['_trackEvent', 'Something', 'Like', response]);
        });
        FB.Event.subscribe('edge.remove', function (response) {
            _gaq.push(['_trackEvent', 'Something', 'Un-Like', response]);
        });
        FB.Event.subscribe('message.send', function (response) {
            _gaq.push(['_trackEvent', 'Something', 'Comment', response]);
        });

Copyright © 2016, Abby Sims