The Like, Share and Send Button available for Web, iOS and Android. The Embedded Posts and Page Plugin are exclusively available for Web.
If a person has visited Facebook and visits your website with a social plugin, the browser sends us information in order to load Facebook content on that page. The data we receive may include info like the person's user ID, the website they're visiting, the date and time, and other browser-related info. We record some of this info and may use it to improve our products and services and to show people more interesting and useful ads.
If you are using the HTML5 or XFBML versions, you should include the language code when you instantiate the library.
When you load the SDK, change the value of js.src
to use your locale. Replace en_US
with your locale, e.g., fr_FR
for French (France):
// Example 1: 'https://connect.facebook.net/fr_FR/sdk.js'; // Example 2: js.src = "https://connect.facebook.net/fr_FR/sdk.js#xfbml=1&version=v2.6";
Supported locales are referenced in the Facebook Locales XML file.
You may need to adjust the width of a Social Plugin to accommodate different languages. Find more information on our Localization & Translation page.
Depending on the Social Plugin you may need to implement a discrete version for Mobile, Tablet or Desktop. Please refer to the FAQ or "Get Started" document for the plugin you wish to implement. Note: It is not recommended to use CSS media queries to adjust the size of Social Plugins.
I need to move a page to a different URL, you can't move the likes, shares or comments directly to the new URL but you can use the old URL as the canonical source for the number of likes or shares at the new URL. We include background on how to do this below.
When resolving which url a like or share action should be attributed to, Facebook uses a process to resolve the canonical url for url that's been loaded. When a URL is loaded, the crawler will look for:
og:url
open graph tag in the pagerel=canonical
as described in RFC 6596. (Facebook's crawler only supports content, not HTTP headers.)If any of these methods result in a URL that's different than the URL originally loaded, the specified URL will be considered the "canonical URL" for the original URL. If required, the crawler will also follow a chain of redirects to find the canonical URL.
All likes and shares will be attributed to the canonical URL instead of the loaded URL.
Hint: Use our debugger to see what Facebook sees when crawling your page.
By controlling the canonical URL you can move content from one URL to another and retain like and share counts, as long as you allow Facebook to continue to resolve the new URL into the old one. This can be done with one of two methods:
og:url
tag to the new URL which points at the old URL (Preferred)In your new URL, you should include a link to the old URL. For example, if your new URL was https://example.com/new-url
, and the old URL was https://example.com/old-url
, you should include this snippet in the new-url
:
<meta property="og:url" content="https://example.com/old-url" />
Using this method tells the crawler that the canonical URL is at the old location, and it will use that to generate the number of likes and shares on the page. Any new likes and shares will continue to aggregate on the old URL as well.
This also requires that the old URL still renders a document with Open Graph tags and returns a HTTP 200 response, at least when loaded by Facebook's crawler. If you want other clients to redirect when they visit the URL, you must send your 301 HTTP response to all non-Facebook crawler clients. The old URL should contain its own og:url
tag that points to itself.
You can learn how to recognize Facebook's crawler in our Sharing Best Practices Guide.
This method will work with rel=canonical
as well, but og:url
is preferred.
Another method to accomplish this is to redirect Facebook's crawler to the old URL any time it visits the new URL. As with the method described above, the old URL must be a valid document with Open Graph headers. And if you want to include a redirect at the old URL, Facebook's crawler must not redirect when it visits the old URL.
Only public content can be embedded. If the post, page, or url has any sort of privacy restrictions, it's not embeddable. This applies to the Like button, Page Plugin, and Embedded Posts and Videos.
A quick way to test if a specific piece of content is embeddable is to try and load it using your browser's "Incognito" or "Private" feature.
The story created by the action of liking, sharing or sending your page can be enriched by using meta tags to turn a simple HTML page into an Open Graph object.
If you plan to use the Like, Share or Send button on any page on your website, you should read our best practices guide to ensure published stories look great on Facebook and get the best possible distribution.
We recommend that you include all buttons on your app or website to let people choose the way that they want to share your content.
The ref
setting causes two parameters to be added to the referrer URL when a person clicks a link from a stream story about a shared link:
fb_ref
- The ref
parameterfb_source
- Like/Share: 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. Send: The story type (message
) in which the click occurred.For example:
http://www.facebook.com/l.php?fb_ref=top_left&fb_source=profile_oneline
You can track these parameters using your analytics software.
If the Like, Share or Send button is placed near the edge of an HTML element with the CSS 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
.
Facebook needs to scrape links shared to Facebook to know which to link preview information to show on Facebook.com or on Facebook for iOS and Android. This happens every 30 days to ensure the properties are up to date. The linked page is also scraped when the URL is entered into the Debugger Tool.
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 30 days.
In some cases you may want to serve a different version of a page to our scraper (containing more Open Graph metadata) than you do to people who are viewing the page. In this case you can target the browser agent used by the scraper:
facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)
Yes. Simply specify the URL of your Facebook page in the href
setting of the button.
There are integrity and spam-prevention safeguards built into social plugins, and this is one of them. If you have been heavily testing a Like button before launching, you may have inadvertently triggered these safeguards. Additionally certain domains on the internet are more likely to contain spam, so will see the confirm step more often.
This confirmation adds one extra step to the Like button process, but once the like has been confirmed separately by a number of users, it will no longer appear, and the regular Like button will only appear.
The number shown is the sum of:
To get code to display the Share button by itself, please visit our Share button documentation.
There are the following options:
Layout | Default Sizes |
---|---|
| Minimum width: 225 pixels. |
| Minimum width: 55 pixels. |
| Minimum width: 90 pixels. |
| Minimum width: 47 pixels. |
The number shown is the sum of:
To get code to display the Share button by itself, please visit our Share button documentation.
Yes, although we recommend using the Share button to offer the simplest and most consistent experience for people using your site, we provide a standalone dialog that can be invoked using the JavaScript SDK or using a URL link. Read our guide to use the Share Dialog.
You can enable the grammar filter from the settings section on the plugin.
The comments for every URL can be accessed via the Graph API. Simply make an HTTP GET request to:
https://graph.facebook.com/v2.6/?fields=og_object{comments} &id=<YOUR_URL> &access_token=<YOUR_TOKEN>
For detailed instructions checkout the Comments Moderation guide. If you're not able to setup the moderators list using the fb:admins
meta property, you can setup the fb:app_id
and update the moderators list in the moderation tool settings for this app.