I would like to apply event tracking in google analytics to facebook comments made on our website via the facebook social plugin (iframe widget), but I can't seem to find a way to attach the event. I would prefer if the solution was jquery based, but honostly I'm open to most any suggestion.
If you remember a specific user by name, you could type in “comments made by <user>” in the Facebook search bar. You can narrow down the search results using the filters on the left. However, this appears to yield more information about people in your friend list or fellow group members.
Analyzing Facebook ads performance in Google Analytics Click on Acquisition, and then select All Traffic and Source/Medium. Then select Campaign from the Secondary dimension dropdown. From this view, you'll be able to analyze the performance and behavior of your users acquired from Facebook ad campaigns.
You can use the Facebook JS SDK Event Subscriptions, specifically comment.create
event callback.
FB.Event.subscribe('comment.create', function(response){
_gaq.push(["_trackEvent", "Facebook Comment", "Posted", response.commentID]);
});
You can also track comment deletions with comment.remove
FB.Event.subscribe('comment.remove', function(response){
_gaq.push(["_trackEvent", "Facebook Comment", "Deleted", response.commentID]);
});
I've tested this, and both appear to work reliably. If you have any troubles, try clearing your cache, and be sure to check the Facebook SDK Status Page.
If you're loading the Facebook SDK asynchronously, those calls should be placed in the asynchronous callback function. If you're loading the SDK synchronously, they just need to be placed lower on the page than the SDK.
The response object will have the commentID
, as well as a href
attribute, and a parentCommentID
, if the comment is a reply to another comment (otherwise, it is set to undefined
).
The href
attribute's purpose is unclear, but its contents appear to be composed as follows:
http://www.facebook.com/plugins/comments_v1.php?app_id=[your-app-id]&xid=276&url=[encodeURIComponent(location.href)]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With