Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Facebook Like Button Google Analytics
// This assumes Facebook buttons are using the Facebook Javascript SDK.
// Thanks to Google for most of this code, see the Social Interaction Analytics guide at
// https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSocial
// Facebook provides a Javascript event framework that allows you to subscribe to events
// happening within the Facebook Javascript SDK and provides data accordingly.
// To track a like, subscribe to the edge.create event and then use the callback to
// execute the Analytics tracking code:
FB.Event.subscribe('edge.create', function(targetUrl) {
_gaq.push(['_trackSocial', 'facebook', 'like', targetUrl]);
});
// To track an unlike, subscribe to the edge.remove event and then use the callback to
// execute the Analytics tracking code:
FB.Event.subscribe('edge.remove', function(targetUrl) {
_gaq.push(['_trackSocial', 'facebook', 'unlike', targetUrl]);
});
// To track a share, subscribe to the message.send event and then use the callback to
// execute the Analytics tracking code:
FB.Event.subscribe('message.send', function(targetUrl) {
_gaq.push(['_trackSocial', 'facebook', 'send', targetUrl]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.