views:

2367

answers:

6

Hello, I am interested in implementing the facebook "Like" button, but I would like to know what user is clicking on this button so I can get some useful information from this. From what I have read, facebook is leaving us in the dark on who is clicking on what. ANyone have an idea on how I could track which user clicked on a like button for a particular product?

UPDATE: The like button is rendered by facebook either through an iFrame, or through xFBML. This is why it is difficult to track who clicks on what, or embed an onclick event, etc..

A: 

It's not so difficult, simply set your callback to the like action. But the realtime facebook API is brand new and yet incomplete.

Mikulas Dite
A: 

If "it's not so difficult", can you whip up some code and paste it here?

Kevin Fox
+1  A: 

OK, so I can let you know how I implemented it. What I wanted to get was the UID of the facebook user clicking on the "Like" button inside my facebook connect app. I noticed when a user clicks on the "like" button, facebook fetches the URL passed to it from the button, so I simply rendered a unique like button for each logged in user with a URL of www.somewebsite.com/thisIsThePageIlike/facebookUID. When a request come to the web server with this url, it works like a callback and I process and record the UID if its the first time a user has clicked "like" (ie.. a record of this 'like' does not exist in the db). works for me.

Matt
A: 
  1. Matt you said -- "When a request come to the web server with this url, it works like a callback". How do you 'catch' the callback? I'm not that knowledgeable regarding backend code. Also, does the user have to be logged in, in order for the callback thing to work or can I just put a random number at the end of the url string?

  2. Is it necessary for the url to have a facebookUID if you aren't interested detailed information? I'm using a like button in a ad banner, and I only need click reporting, that doesn't require any sophisticated info. Considering that, do I need to make the POST url string unique at all, if I'm just tracking plain ol' clicks?

Big thanks to anyone that can answer these questions, much appreciated. Matt thank you for taking time to share your solution :)

Kevin Fox
Kevin, Take a look at how the facebook like button params. One is a url - that is the url that facebook fetches. This fetch can be captured and processed like any other request if you are running a script on the webserver. Typically, facebook "like" items represent a single, unique objectie.. web page, physical object..etc that all have unique URLs. When the "Like" gets posted to facebook, people can click on it and linked to that page. For your ad banner issue, if you just want to track how many people like it, facebook can tell you that if you include your fb id in the like button params
Matt
I almost forgot. You must remove the unique identifier from the url in the meta data on the page facebook calls back or you will have unique URLS and your "likes" will not aggregate
Matt
I forgot to mention that the client does not want to get analytic data from some facebook account. There is already an analytics pool of data being tracked. This action needs to be added to that pool. The 'like' button click needs to be routed to a JS function. How would you do that? I tried capturing the outbound click action on the page via a div mousedown etc. but these outbound methods either fired the facebook call or the JS call but never both at the same time. So I'm guessing I need to 'listen' for the call that is coming back? Is that possible? Thanks for your time in advance.
Kevin Fox
+2  A: 

Has anyone got this working?

http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe


  // this will fire when any of the like widgets are "liked" by the user
  FB.Event.subscribe('edge.create', function(href, widget) {
    Log.info('You liked ' + href, widget);
  });

staticnullvoid
Yes. However, it does not trigger a callback on Unlike.
Swanand
There is a request out there, on the Developers forum, for an unlike event to be added.
staticnullvoid