Facebook Developers
DocsToolsSupportNewsApps
Log In
  • Getting Started
  • Core Concepts
    • Social Design
    • Social Plugins
    • Facebook Login
    • Dialogs
    • Open Graph
  • Advanced Topics
  • Technical Guides
  • API Reference
  • SDK Reference
  • Plugins
    • Activity Feed
    • Comments
    • Facepile
    • Like Box
    • Like Button
    • Live Stream
    • Login Button
    • Recommendations Bar
    • Recommendations Box
    • Registration
    • Send Button
    • Share Links
    • Shared Activity
    • Subscribe Button
    • fb:name
    • fb:profile-pic
  • Beta Plugins
    • Migrations

      Like Button

      Core Concepts › Social Plugins › Like Button

      Migration: We recently updated how the Like button social plugin will function with respect to content restrictions, publishing updates to users and integration with the Built-in Like action. Please read the following developer doc about the Like Button Migration.

      The Like button lets a user share your content with friends on Facebook. When the user clicks the Like button on your site, a story appears in the user's friends' News Feed with a link back to your website.

      When your Web page represents a real-world entity, things like movies, sports teams, celebrities, and restaurants, use the Open Graph protocol to specify information about the entity. If you include Open Graph tags on your Web page, your page becomes equivalent to a Facebook page. This means when a user clicks a Like button on your page, a connection is made between your page and the user. Your page will appear in the "Likes and Interests" section of the user's profile, and you have the ability to publish updates to the user. Your page will show up in same places that Facebook pages show up around the site (e.g. search), and you can target ads to people who like your content. Note: The count on the Like button will include all likes and shares whereas the like connection on the Graph API includes only the number of likes for the object.

      There are two Like button implementations: XFBML and Iframe. The XFBML (also available in HTML5-compliant markup) version is more versatile, but requires use of the JavaScript SDK. The XFBML dynamically re-sizes its height according to whether there are profile pictures to display, gives you the ability (through the Javascript library) to listen for like events so that you know in real time when a user clicks the Like button, and it always gives the user the ability to add an optional comment to the like. If users do add a comment, the story published back to Facebook is given more prominence.

      Note: The URLs in the code are protocol relative. This lets the browser load the SDK over the same protocol (HTTP or HTTPS) as the containing page, which will prevent "Insecure Content" warnings. Missing http and https in the code is intentional.

      To get started, just use the configurator below to get code to add to your site.

      Step 1 - Get Like Button Code

      (?)
      Send Button (XFBML Only) (?)
      (?)
      standard
      • standard
      • button_count
      • box_count
      (?)
      Show Faces (?)
      (?)
      • arial
      • lucida grande
      • segoe ui
      • tahoma
      • trebuchet ms
      • verdana
      (?)
      light
      • light
      • dark
      (?)
      like
      • like
      • recommend
      Get Code

      Attributes

      • href - the URL to like. The XFBML version defaults to the current page.
      • send - specifies whether to include a Send button with the Like button. This only works with the XFBML version.
      • layout - there are three options.
        • standard - displays social text to the right of the button and friends' profile photos below. Minimum width: 225 pixels. Minimum increases by 40px if action is 'recommend' by and increases by 60px if send is 'true'. Default width: 450 pixels. Height: 35 pixels (without photos) or 80 pixels (with photos).
        • button_count - displays the total number of likes to the right of the button. Minimum width: 90 pixels. Default width: 90 pixels. Height: 20 pixels.
        • box_count - displays the total number of likes above the button. Minimum width: 55 pixels. Default width: 55 pixels. Height: 65 pixels.
      • show_faces - specifies whether to display profile photos below the button (standard layout only)
      • width - the width of the Like button.
      • action - the verb to display on the button. Options: 'like', 'recommend'
      • font - the font to display in the button. Options: 'arial', 'lucida grande', 'segoe ui', 'tahoma', 'trebuchet ms', 'verdana'
      • colorscheme - the color scheme for the like button. Options: 'light', 'dark'
      • ref - a label for tracking referrals; must be less than 50 characters and can contain alphanumeric characters and some punctuation (currently +/=-.:_). The ref attribute causes two parameters to be added to the referrer URL when a user clicks a link from a stream story about a Like action:
        • fb_ref - the ref parameter
        • fb_source - the stream type ('home', 'profile', 'search', 'ticker', 'tickerdialog' or 'other') in which the click occurred and the story type ('oneline' or 'multiline'), concatenated with an underscore.

      Step 2 - Get Open Graph Tags

      (?)
      (?)
      • Chose a type
      • activity
      • actor
      • album
      • article
      • athlete
      • author
      • band
      • bar
      • blog
      • book
      • cafe
      • cause
      • city
      • company
      • country
      • director
      • drink
      • food
      • game
      • government
      • hotel
      • landmark
      • movie
      • musician
      • non_profit
      • politician
      • product
      • public_figure
      • restaurant
      • school
      • song
      • sport
      • sports_league
      • sports_team
      • state_province
      • tv_show
      • university
      • website
      (?)
      (?)
      (?)
      (?)
      Get Tags

      Open Graph Tags

      Open Graph tags are <meta> tags that you add to the <head> of your website to describe the entity your page represents, whether it is a band, restaurant, blog, or something else.

      An Open Graph tag looks like this:

      <meta property="og:tag name" content="tag value"/> 
      

      If you use Open Graph tags, the following six are required:

      • og:title - The title of the entity.
      • og:type - The type of entity. You must select a type from the list of Open Graph types.
      • og:image - The URL to an image that represents the entity. Images must be at least 50 pixels by 50 pixels (though minimum 200px by 200px is preferred). Square images work best, but you are allowed to use images up to three times as wide as they are tall.
      • og:url - The canonical, permanent URL of the page representing the entity. When you use Open Graph tags, the Like button posts a link to the og:url instead of the URL in the Like button code.
      • og:site_name - A human-readable name for your site, e.g., "IMDb".
      • fb:admins or fb:app_id - A comma-separated list of either the Facebook IDs of page administrators or a Facebook Platform application ID. At a minimum, include only your own Facebook ID.

      More information on Open Graph tags and details on Administering your page can be found on the Open Graph protocol documentation .

      FAQ

      How do I know when a user clicks a Like button?

      If you are using the XFBML version of the button, you can subscribe to the 'edge.create' event through FB.Event.subscribe.

      When will users have the option to add a comment to the like?

      If you are using the XFBML version of the Like button, users will always have the option to add a comment. If you are using the Iframe version of the button, users will have the option to comment if you are using the standard layout. If users do add a comment, the story published back to Facebook is given more prominence.

      What analytics are available about the Like button?

      If you visit facebook.com/insights and register your domain, you can see the number of likes on your domain each day and the demographics of who is clicking the Like button.

      Can I link the Like button to my Facebook page?

      Yes. Simply specify the URL of your Facebook page in the href parameter of the button.

      What is the best way to know which Like button on my page generated the traffic?

      Add the 'ref' parameter to the plugin (see "Attributes" above).

      Examples:

      <fb:like ref="top_left"></fb:like>
      <iframe src="...&ref=top_left"></iframe>
      

      When a user clicks a link back to your website, we will pass back both the ref value as a fb_ref parameter and the fb_source parameter in the referrer URL. Example:

      http://www.facebook.com/l.php?fb_ref=top_left&fb_source=profile_oneline
      

      Aggregated stream stories contain all ref parameters, concatenated with commas.

      When does Facebook scrape my page?

      Facebook needs to scrape your page to know how to display it around the site.

      Facebook scrapes your page every 24 hours to ensure the properties are up to date. The page is also scraped when an admin for the Open Graph page clicks the Like button and when the URL is entered into the Facebook URL Linter. Facebook observes cache headers on your URLs - it will look at "Expires" and "Cache-Control" in order of preference. However, even if you specify a longer time, Facebook will scrape your page every 24 hours.

      The user agent of the scraper is: "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)"

      How do I display the Like button in different languages?

      If you are using the XFBML version include the language code when you instantiate the library. Replace ‘en_US’ in this line with the correct locale code:

      '//connect.facebook.net/en_US/all.js';
      

      If you are using the Iframe version include a locale parameter with the proper country code in the src URL. Example:

      src="http://www.facebook.com/plugins/like.php?locale=fr_FR&..."
      

      You may need to adjust the width of the Like button to accommodate different languages.

      What makes up the number shown on my Like button?

      The number shown is the sum of:

      • The number of likes of this URL
      • The number of shares of this URL (this includes copy/pasting a link back to Facebook)
      • The number of likes and comments on stories on Facebook about this URL

      What happened to the old Share button?

      We deprecated the Share Button when we launched the Like button, because the Like button improves clickthrough rates by allowing users to connect with one click, and by allowing them to see which of their friends have already connected. For reference, the Share button documentation is still available here.

      When I click the Like button, the popup window (or "flyout") doesn't show. Why?

      If the Like button is placed near the edge of an HTML element with the overflow property set to hidden, the flyout may be clipped or completely hidden when the button is clicked. This can be remedied by setting the overflow property to a value other than hidden, such as visible, scroll, or auto.

      Updated about a month ago
      Facebook © 2012 · English (US)
      AboutAdvertisingCareersPlatform PoliciesPrivacy Policy