How to Add a Like Button to Your Facebook Tabs

social media how toHave you ever wondered how certain Facebook pages add Like buttons to their custom tabs? Look no further.

Many have asked me how sites like Threadless are able to add multiple Like buttons and comments to their Fan page, allowing visitors to buy, Like and comment on any t-shirt on their Shop tab.

Well, it turns out it’s actually quite easy, using the fb:comments FBML tag.

Using fb:comments, you can add a Like button and comment boxes in multiple places on your Facebook tabs and, optionally, each can be accompanied by a user comments section. This provides more avenues for fans to interact with, and share, your content.

The Threadless Fan Page — How Do They DO That?

The Threadless Fan Page “Shop” tab displays a selection of six t-shirts from their catalog, and visitors can order, Like and/or comment on each one.

threadless

Each Threadless product has "Add to cart," a Like button, and Comments.

The left column in the above illustration is a product image and a pull-down select option. Once a user makes a selection and clicks “Add to cart,” he or she is redirected to the Threadless.com website to complete the purchase.

The right column content is created using the fb:comments FBML tag:

<fb:comments xid=”UNIQUE-IDENTIFIER” canpost=”true” candelete=”false” reverse=”true” returnurl=”http://www.threadless.com/product/1295/And_How_Are_You_Feeling_Today”>
<fb:title></fb:title>
</fb:comments>

The parameters and values used for fb:comments

  • xid: This is the unique identifier for this instance of the fb:comments tag. You must include a value, and I suggest using something short and descriptive. You’re limited to alphanumeric characters, hyphens, the percent sign, periods and underscores. The user won’t see this content; it’s just for creating a value that can be accessed by developers for programming purposes.
    Some examples are:
    xid=”Product-205″
    xid=”Product-Blue-Shoes
    xid=”Tan_50%”
  • canpost: You’ll most likely want “true” for this value, indicating the user can post a comment.
  • candelete: You’ll want “false” for this, meaning a user can’t delete any of the comments.
  • reverse: Setting this to “true” places the “Add a Comment” box below the posted comments, as is done on the Threadless page.
  • returnurl: This is the most important value! This is the URL that the user is Liking when he or she clicks the Like button. If the user ticks the “Post comment to my Facebook Profile” box, the comment will appear on their wall as “[User] likes [Website’s Title Tag] on [URL].” You can have any valid URL for the “returnurl” parameter. Threadless has the product’s page on their website as the “returnurl” value.

Using CSS to hide unwanted elements in the fb:comments tag

You can remove that "Facebook social plugin" text and logo with CSS.

You can easily hide this element from being displayed. Using the Firefox plugin “Firebug” (a must-have for coders!), I determined that the little Facebook logo and “Facebook social plugin” text are contained in a DIV assigned the class “subtitle_left“, and this DIV can be hidden, in all browsers, with CSS.

To hide this content, you simply add:

.subtitle_left {display:none;}

to your stylesheet, which hides the DIV:

Presto! The containing DIV for the logo and text are hidden with display:none.

Just want the Like button? Use CSS to hide the comment box

If you want only the Like button and not the comments box, you can use the “display:none” CSS property to hide the unwanted comments box.

Because all the comment features are contained in a DIV assigned the class “comment_body” (thanks again, Firebug!), just add the following CSS rule to your stylesheet:

.comment_body {display:none;}

The result:

Adding Multiple Instances of the Like Button

You can have as many instances of the fb:comments FBML tag on your custom tab as you wish. Just make sure that each has a unique “xid” value.

Giving users more options than just Liking your page and/or sharing it means more user engagement and more mentions of your brand showing up on users’ walls.

Give it a try and let us know how it works. Leave your questions and comments in the box below.

Tags: , , , , , , , ,

About the Author, Tim Ware

Tim Ware is the owner of HyperArts, a San Francisco Bay Area Web development company that also specializes in Facebook custom tabs and application development. Other posts by »




More Info
  • John

    “you simply add: .subtitle_left {display:none;} to your stylesheet.”

    What stylesheet ? Its a Facebook Tab with no stylesheets.

    Can you explain that please ?

    Thanks.

  • http://www.colemanmg.com Antonio Coleman

    Tim..I didn’t know this was possible..thanks for the heads up..I will test this out today on my fan page.

    “Black Seo Guy “Signing Off”

  • Sune

    Hi Tim.
    Thanks for the run-down – is it posible to make the like button for the Facebook page itself, in effect making an dynamic version of now videly used static call for users to press the “like” button (often with an arrow pointing to the “like” button on top)? Thanks. Best, Sune

  • http://www.hyperarts.com/blog/ Tim Ware

    You can use the fb:comments to have the user Like the Page using the button it generates, by inputting the full URL to the Page as the “returnurl” value.

    The drawback is that, unlike when a user clicks the main Like button at the top of the Page, the Page is not automatically refreshed to indicate that the user is now fan of the Page. With the fb:comments-generated Like button, after clicking it the user has to manually reload/refresh the Page to see the new status.

  • http://www.hyperarts.com/blog/ Tim Ware

    This article is about using the FBML tag fb:comments on a custom tab, and custom tabs can utilize external stylesheets (preferred for compatibility with Internet Explorer) or inlined styles.

  • Julie Berglund

    First point: This is fantastic information! I have a number of FB pages I help run for folks, and I know this will be helpful for them. That said, I’m wondering about the timing of this info…

    I just heard (yeah, I know, I’m probably a bit behind in the FB news ring) about FB’s move from FBML to iFrames for page tabs (http://blog.lujure.com/2010/12/05/hello-world/). That they will continue to support FBML tabs through Q1 of 2011, but want people to start moving to iFrames asap.

    What does this mean for the information you posted here? Will we even be able to continue using tags like fb:comments when we create new ‘page tabs’ using iFrames?

  • Jcruz

    How would you add the comments total for a given xid so it shows along side the Like button?

  • http://drhariri.com/ Abdulrahman Hariri

    What is the difference between doing it this way or simply using:
    ?

    Thanks!

  • http://drhariri.com/ Abdulrahman Hariri

    Was referring to this:
    http://fbrell.com/xfbml/fb:like

  • http://twitter.com/SurefireSocial Surefire Social

    Great Post. We build Facebook pages (including FBML tabs) for our local, small business clients. The FBML application is a great way to grow your marketing list (by having people sign up for something) and promote certain services or products.

    Here is a little FBML “cheat sheet” that facebook put out where you can use different commands to add more viral elements to your facebook landing page.

    Enjoy!

    http://developers.facebook.com/docs/reference/fbml/

  • http://www.facebook.com/dror.tirosh Dror Tirosh

    Hey Tim,

    Thanks for the article, a few additions:

    1. as for Julie’s question, this is very relevant and indeed FB said they will stop support of the FBML pages initially by Dec 2010, and now by the end of 1st Qtr 2011. But at the moment the only way to add a Tab to your page is through FBML, the Iframe option is not yet available, so at least for the short term this is the only solution. Also moving from simple FBML to HTML is very straight forward and most web programmer will be able to help you with this when the time comes.

    I will also recommend using the url attribute with the returnurl and give it exactly the same URL as the returnurl, as that is the name FB will be using in Iframes.

    2. FB uses the returnurl/url attributes to look for graph protocol info on that page (details in http://ogp.me/), so when someone like, comment on your post when shown on their feed it can show more details and even photos taken from the open graph details on the page refered to by the returnurl/url.

    3. very important to keep the xid unique for your application, for example threadless uses something like ‘th_2526_comment_box’ so that other applications will not use the same xid by mistake.

    Hope this helps

  • JessH

    So I am assuming Im doing something wrong here because your code is not working. I replaced your “unique-identifier” with one word and put the url to my fb page, is there something I should know about?

  • JessH

    Also, I am using Static fbml, does this tag only work on canvas pages?

  • http://mai.do/ Gabriele Maidecchi

    This is definitely one of those posts I will have to bookmark on Delicious for future reference. Very nice read, thanks for sharing.

  • Julie Berglund

    Dror, Thanks for the added info. And, you’re correct: as long as FBML still works, this is definitely great article. In fact, I’ll be able to use this information this week for a couple of the pages I admin.

    I’m a website designer and have the HTML background, so I have to admit that I am looking forward to (hopefully) being able to ‘play’ a bit more with the changeover to iFrames in place of FBML. It should be an interesting switch.

    Thanks for the input!

  • Dating

    I’ve read about this – once and a while thru the past six months waiting for the day someone posted the code needed for a copy paste routine… Still no luck.

    Im doing like this:

    it works!

    What is it that im not doing, that you are in someway taking for granted i should know about using the fb:comment tag?

  • http://drhariri.com/ Abdulrahman Hariri

    I think it only works in Canvas pages.

  • oman_intel

    Hi Tim,
    good work as usual. The code works fine with me but i can’t manage to include the “.subtitle_left {display:none;}” class. Where exactly do you insert it? Right at the end? Thanks…as usual!!!

  • http://brandyousocial.com Karl Sly

    Tim, it was a nice surprise to see you on here. I love your blog by the way! Thanks for sharing more great FBML Tips.

  • Kurtis Griess

    John,

    Here’s how you can add the stylesheet easily in two steps:

    1. Under “Edit Profile”, go to the application that you are adding the comment box and Like box to (where you inserted the ).

    2. Insert the following code above the code:

    .subtitle_left {display:none;}

    That’s how I got it to work on my page! I hope it works for you too.

  • http://compassionbythebook.com Kurtis Griess

    John,

    I got it to work by inserting the following code above the … that was given in Tim’s post:

    .subtitle_left {display:none;}

    I hope that helps!

  • Kurtis Griess

    Hey Maurizio,

    I got it to work by inserting the following code above the … that was given in Tim’s post:

    .subtitle_left {display:none;}

    I hope that helps!

  • http://www.hyperarts.com/blog/ Tim Ware

    Hi Julie, So many people are asking about the future of Static FBML and FBML tags that I wrote a post to try to put to rest the confusion around Facebook’s statements regarding FBML, iFrames and the rest. Read my post about the future of Static FBML and FBML.

    The short answer to your question is that FBML, the mark-up language, is being deprecated, meaning Facebook will not do any further development or improvements on the language, but just let it fade away over time.

    FBML canvas applications, however, is what Facebook now intends to eliminate in Q1 2011.

    Facebook, on its Static FBML application page, continues to tout its benefits. When they decide to eliminate it, you will see an announcement on the app page.

  • AJ

    also, if i copy the example code straight from fb wiki on fb:comments, add it to a new static fbml app on my page, it does NOT post comments to my wall, even when the box is checked. what am i doing wrong????

  • AJ

    posted this earlier, but it doesnt appear to have posted…

    the way to add css to static fbml is like this:

    above all your code in the FBML box, add the following:

    .subtitle_left {display:none;}

    edit css to your liking.

    now, here’s my problem: i admin a page; i add a FBML “app” to the page; i added a few images and the fb:comments code. everything works perfectly, except… when i post a commen and check the “post comment to my fb profile” box, it DOES NOT post the comment to my feed.

    i posted a comment on the threadless page and it posted to my feed instantly.

    any ideas?

  • http://www.hyperarts.com/blog/ Tim Ware

    “.subtitle_left” is a Facebook-generated CSS class that’s applied to a containing DIV that has the stuff you want to hide. So you give it the rule “display: none” and that hides the display. You would put this in your stylesheet for your Static FBML tab, which should be an external file so that it works with Internet Explorer. Read this post on external stylesheets, Internet Explorer and Static FBML.

  • http://www.hyperarts.com/blog/ Tim Ware

    Great additional info on my post, Dror! I would only add that, per an article I just posted clarifying the end-of-FBML confusion, Facebook intends to continue support for Static FBML, per their August 10, 2010 announcement, where they stated: “We will, however, continue to support existing implementations of the older authentication mechanism as well as FBML on Page tabs and applications.”

  • http://www.hyperarts.com/blog/ Tim Ware

    AJ, Actually that is one way to add CSS to your FBML box, but it’s definitely not the BEST way to do it, because Internet Explorer ignores the styles in the … tag. You have to use an external stylesheet and incorporate it into your Static FBML tag with the tag.

    As for the comment not posting to your Wall, sometimes they don’t show up at the very top, but down the page a bit, with other one-line items about what you’ve recently Liked etc.

  • oman_intel

    Thanks Tim, i’ll look into that. So are you saying that people using IE won’t be able to read “fb:comments” unless i’m using an external stylesheet? Thanks.

  • http://www.hyperarts.com/blog/ Tim Ware

    No, Maurizio. I’m saying that IE doesn’t parse/read the styles that are inside the … tags. It does interpret the fb:comments tag correctly. But for using CSS that IE reads, you have to use an external stylesheet called into your FBML box with the tag.

  • http://www.lorirtaylor.com/ LoriRTaylor

    This was a great article. I am consultant to ThisNext.com and sent them this link as I think they should mimic the Threadless example. Nice easy to read post.

  • http://www.hyperarts.com/blog/ Tim Ware

    Thanks Lori! Music to my ears :)

  • http://www.hyperarts.com/blog/ Tim Ware

    AJ, Actually that is one way to add CSS to your FBML box, but it’s definitely not the BEST way to do it, because Internet Explorer ignores the styles in the … tag. You have to use an external stylesheet and incorporate it into your Static FBML tag with the tag.

    As for the comment not posting to your Wall, sometimes they don’t show up at the very top, but down the page a bit, with other one-line items about what you’ve recently Liked etc.

  • http://www.facebook.com/dror.tirosh Dror Tirosh

    Should work in both, I have used it in static FBML many times before.
    Make sure your xid is unique, which means not unique in your app but unique in any potential app (using the app name as part of it will help)

    check for exact syntax here – http://developers.facebook.com/docs/reference/fbml/comments

  • http://www.facebook.com/dror.tirosh Dror Tirosh

    You should see your comment on your profile page, not on your feed.
    For a comment or any other message to show on your feed it requires FB to decide it is relevant enough.
    It is worth checking with friends of yours who are also fans of your page if they see your comment, as for them it will be relevant.

  • Jessica Lopez

    The code initially didn’t work for me when copying & pasting because the quote marks pasted specialized characters created by HTML, rather than straight “. Once I deleted the stylized quotes and manually typed them, the code worked. Good luck!

  • http://www.hyperarts.com/blog/ Tim Ware

    Hi Dating. There are some pretty serious problems with the code you pasted in. It looks like you’re putting double double quotation marks around all the parameter values, and that will break your tag right there. Just one set of double quotes will suffice: candelete=”false” NOT candelete=””false””.

    Also, the … tags aren’t need anymore.

    I think if you follow my example in this post you’ll have better results. I hope this helps!

  • http://www.hyperarts.com/blog/ Tim Ware

    Thanks Gabriele. You are certainly welcome!

  • AJ

    thanks for the response!!! i definitely meant profile, not feed – sorry! and just to make sure we’re on the same page (haha, it’s so punny) – i’m talking about clicking “profile” in the top right corner. when i post a comment in the tab of the page i admin, it never makes it to my profile. :(

  • http://jobspert.com/placement-papers/ John Papers

    Thank you for share this information..
    John..

  • Johnfpor

    I’m having the same problem, the box is checked to post to profile but it doesn’t end up at my profile?? also I tried on a friends page who is not an admin and it doesn’t appear on their profile either?

    I presume there is some piece of code missing. But it’s really important to get it to work as it a big part of spreading your content!

    By the way thanks Tim for this very helpful article!!

  • http://twitter.com/shermanunkefer Sherman Unkefer

    Thanks for the rundown on this, finally was able to get the button to display on some sites. I’ll definitely consult this blog for future needs.

  • awesomeosaurustshirts

    Great article, thanks!

    Could you please highlight Jessica Lee’s comment about the type of quotation marks being used? I done a straight copy and paste from your example and spent a while figuring out why it wasn’t working until I resorted to reading the comments. The default text size of Facebook made this very difficult to spot initially.

    All the best, Karl

  • Pingback: Linkswitch #48: Estimates & Homemade Gifts()

  • Adam Evers

    Now the real questions is how to get the profile pictures that small!

    Any ideas?

  • Pingback: Find Time to Add Some Flexibility and Fun to Your Facebook Page! | The Time Finder with Paula Eder()

  • http://www.facebook.com/krzysztof.romanowski Krzysztof Romanowski

    fb:comments tag has also one attribute: publish_feed=”BOOL-TRUE-FALSE” . This attribute check/uncheck by default checkbox for “Publish comment for my facebook profile”

  • David B

    Have you managed to solve this issue? I experience it too. Any help is appreciated thanks :)

  • Teammaxed

    I don’t think I will ever get how this codeing thing works. I’m an old dog trying to learn a new trick. I always see people explain it as easy to do. And it’s a foreign language to me. It can not be explained in basic enough terms for me to understand.
    I fight with this every day. And am getting no where. But I keep punnishing myself readind it and trying anyway.

  • AJ

    i really wish i had… i’ve looked through the fbml tutorials on facebook and the code looks exactly the same to me. but even when i copy their example code and put it on my page, it does NOT work. haha! would still love to find a solution if anyone has a suggestion!

  • AJ

    hey tim, thanks for the correction – i didnt realize IE wouldnt parse internal css!!! i can make that change easily enough. but i’m still having the issue with posts not appearing on my profile… i posted another test comment just now, waited a minute, and checked my profile. it didnt show up anywhere on my profile. any ideas of things i can try with my code? this is the fbcomments snippet of code i’m using:

    Sean Title

  • http://www.irisemedia.com iRISEmedia
  • earnerblogs.blogspot.com

    its really nice and cool

  • http://www.facebook.com/david.goodlin David Goodlin

    If you just want the like button, how would go about removing the profile images that pull through once you have clicked like?

    In other words, outside of a facebook tab you have the ability of using fb:like and it gives you the option to hide profile photos. How do you do that with FB:comments within a facebook tab?

  • oman_intel

    Thank you! Will give it a try.

  • Pingback: Static FBML Tags to Display Username or Random Messages on Fan Pages | HyperArts()

  • oman_intel

    Hello again Time; do you know how this guy managed to welcome a user by his name? http://www.facebook.com/MichaelJacksonTheKing0fPop

  • @byl

    Try this ;-)

    .comment_body {display:none;}
    .subtitle_left {display:none;}
    .connect_widget_sample_connections {display:none;}
    .wallkit_title {display:none;}

    Your web site title

  • kevupnorth

    Another question:

    I’m doing a page for an organisation that doesn’t have hosting. The wanted a link to a PDF file, so I put it on my webspace. I now want people to “like” this document, so set up a button as described in your really useful article. However, it then comes up: “Kevin liked the document on Campbellwright.co.uk”. Fine, but I don’t want to highlight that the document is on my server.

    I notice that LikeFuzz, a page that allows people to like bizarre statements, masks this and show as “Kevin liked this document on ♥. Any idea how they do this?

  • zaned

    Is it possible to add a fb:comment to each image in my static fbml? I have made a simple static fbml with images. So, I really want to add a fb:comment for each of them.
    Thank you in advance for your help.

  • Gustavo

    Thanks Jessica.
    That worked for me

  • Gustavo

    Does anybody knows how to get the comment box smaller like in threadless’s box?

  • Katia

    How do i add a LIKE and REPLY button to the COMMENT

  • Viren Shah

    How can we change the layout of the like button which comes with fb-comment

  • kachod

    Is it allowed to remove elements like the Facebook logo and “Facebook social plugin” text?

  • kachod

    I mean is it allowed by Facebook?

  • milez

    Why not just use ? If you look at threadless’ source, they do it actually.

  • http://www.facebook.com/piattos.vn Piattos Vietnam

    I tried many times but it still couldnt work :(

    I’m using Static HTML for my page.

  • Manas Padfoot

    where do u guys insert this code exactly??

  • Bondre Gunal

    i want just like box………not even show how many people liked it…….is it possible

  • Regan

    It would be nice if you had a “how to do this for dummies” explanation. I’m fairly tech savvy (I set up my own blog, website, Facebook, Twitter, etc. accounts) but I had trouble following this.

  • Sashanait

    I’m just wondering is it is possible to add a like box to a note on my fan page in facebook?









Pinterest
Join our Social Media Marketing Networking Club
Check out the Social Media Marketing Podcast!