Facebook "Like" button callback

71,699

Solution 1

<script>
  FB.Event.subscribe('edge.create', function(href, widget) {
    alert('You just liked the page!');
  });
</script>

Solution 2

so I simply rendered a unique like button for each logged in user with a URL of www.somewebsite.com/thisIsThePageIlike/facebookUID.

won't this defeat the purpose of having a like button and mess up your facebook search ranking? Every user will be liking a different url and so facebook will think you have a ton of pages each with a single like count.

I am also having an issue with XFBML like buttons where the edge.create event isn't firing

Solution 3

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.

Share:
71,699
Admin
Author by

Admin

Updated on July 09, 2022

Comments

  • Admin
    Admin almost 2 years

    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..

  • shem
    shem over 11 years
  • jameshwart lopez
    jameshwart lopez over 5 years
    this seems to be not working. looks like im missing something so obvious to others. :(
  • jameshwart lopez
    jameshwart lopez over 5 years
    can someone point me out what im missing on this question stackoverflow.com/questions/52042404/…
  • andonovn
    andonovn over 3 years
    At least make sure your code is syntactically valid before posting it publicly, especially on platforms like SO where you are supposed to help others