开发者

How do I track Facebook Like Button clicks?

I am building a simple website. I am going to put Facebook Like Button on each article page of this website. How can I track how many people Liked this particular article? Does facebook开发者_C百科 provide an API for that?

Clarification

I am going to write a script that is going to pull the amount of "likes" for each page every hour. This would allow me to build a popularity graph.


You will need to run FQL on link_stat table providing url of your article and retrieving like_count field. You can run FQL using FB.Data.query() from JS SDK.


Yes, facebook provides this type of functionality. Have a look at this widget which currently counts the number of likes for each page of your site.

Alternatively, you can use something like this which produces something along the lines of the following: 37,416 people like this. Be the first of your friends.


HI, Check this page...it has a wizard to help you generate the code for a like button:

http://developers.facebook.com/docs/reference/plugins/like

But basically all you need is this bit of code:

<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fgoogle.com&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>

and where it says http%3A%2F%2Fgoogle.com just replace that with your url...being careful to make sure the special characters (i.e. the question marks, colons, forward slashes) in your url are encoded using hex characters (you can find all the corresponding hex tags here: http://www.obkb.com/dcljr/charstxt.html)....this way if your article pages are dynamic (i.e. generated by a server side script) then you can just spit the url out in to this iframe code above.

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜