Orchard Core Facebook and Meta Integration
OrchardCore.Facebook is the Meta core feature. It is
EnabledByDependencyOnly; do not try to enable it directly. Enable a
dependent feature instead:
| Feature ID | Purpose |
|---|---|
| OrchardCore.Facebook.Login | External Meta authentication |
| OrchardCore.Facebook.Widgets | Meta social-plugin widgets |
| OrchardCore.Facebook.Pixel | Meta Pixel tracking and the Conversions API |
The Login and Widgets features bring in the core feature. Pixel is independent.
Meta App Settings
Configure the core app at Settings → Integrations → Meta App. The backing
FacebookSettings properties are AppId, AppSecret, FBInit,
FBInitParams, SdkJs, and Version. The module's dedicated recipe step is
FacebookCoreSettings:
{
"steps": [
{
"name": "Feature",
"enable": [
"OrchardCore.Facebook.Login"
]
},
{
"name": "FacebookCoreSettings",
"AppId": "meta-app-id",
"FBInit": true,
"FBInitParams": "status: true, xfbml: true, autoLogAppEvents: true",
"SdkJs": "sdk.js",
"Version": "v3.2"
}
]
}
The app secret is stored data-protected when saved from the admin page, and
the login handler decrypts it. A secret written by a recipe is stored as is
and cannot be decrypted, so supply AppSecret through the admin page or
configuration instead. The step replaces all core values, so re-running it
clears a secret entered earlier.
In 4.0, FacebookSettings.AppSecretSecretName can name a TextSecret of the
Secrets module instead; it takes precedence over AppSecret. With the
OrchardCore.Secrets feature enabled, the Meta App page offers **Use a
secret** (suggested name Facebook.AppSecret), and a saved secret can be moved
without retyping it from Tools → Security → Migrate Secrets. The generic
Settings step can set "AppSecretSecretName": "Facebook.AppSecret" in
FacebookSettings after a Secrets step created the secret; FacebookCoreSettings
has no secret-name property. The Pixel ConversionsApiAccessToken can't
reference a secret. See orchardcore-secrets.
Configuration Overrides
Call ConfigureFacebookSettings() on the OrchardCoreBuilder to override the
stored core settings from configuration:
builder.Services
.AddOrchardCms()
.ConfigureFacebookSettings();
{
"OrchardCore": {
"Facebook": {
"AppId": "meta-app-id",
"AppSecret": "plain-app-secret",
"FBInit": false,
"FBInitParams": "status:true,xfbml:true,autoLogAppEvents:true",
"SdkJs": "sdk.js",
"Version": "v3.2"
}
}
}
The configured AppSecret is a plain value (for example from the
OrchardCore__Facebook__AppSecret environment variable or a key vault); Orchard
Core protects it before use. In 4.0 it logs a LegacySecretConfiguration
warning (event 8100). The section binds onto FacebookSettings, so set
AppSecretSecretName here instead to reference a secret, and remove AppSecret.
Meta Login
Enable OrchardCore.Facebook.Login, which depends on
OrchardCore.Users.ExternalAuthentication. Configure it at
Settings → Security → Authentication → Meta. The callback defaults to
/signin-facebook; register the tenant's full HTTPS callback URL with Meta.
{
"steps": [
{
"name": "FacebookLoginSettings",
"CallbackPath": "/signin-facebook"
}
]
}
The FacebookLoginSettings step persists the callback path only. To also set
SaveTokens, use the generic Settings step with a FacebookLoginSettings
object (CallbackPath, SaveTokens).
Enable OrchardCore.Users.Registration only when external users should be
able to create local accounts; external-user creation is controlled by
ExternalRegistrationSettings (see orchardcore-users-roles).
Social Plugins Widgets
Enable OrchardCore.Facebook.Widgets to get the FacebookPluginPart and the
Chat, Comments, Continue With, Like, Quote, Save, and Share widgets.
The FacebookPluginPart body is an executable Liquid template. Editing it
requires the security-critical ManageLiquidTemplates permission, which is
also required to edit or publish any content containing the part, including
widgets embedded recursively inside other content items. Grant it only to
trusted roles.
Load the SDK in templates when a page needs it (resources fb and fbsdk):
{% scriptresource name: "fbsdk" %}
Meta Pixel and Conversions API
Enable OrchardCore.Facebook.Pixel and configure
Settings → Integrations → Meta Pixel:
- Pixel Identifier (
PixelId) for browser-side tracking. - Conversions API Access Token (
ConversionsApiAccessToken), generated in Events Manager for the pixel's dataset; stored encrypted. - Test Event Code (
ConversionsApiTestEventCode), optional; events go to the Events Manager test console. Remove it before going live.
{
"steps": [
{
"name": "Feature",
"enable": [
"OrchardCore.Facebook.Pixel",
"OrchardCore.Workflows"
]
},
{
"name": "Settings",
"FacebookPixelSettings": {
"PixelId": "your-pixel-id",
"ConversionsApiTestEventCode": "TEST12345"
}
}
]
}
Enter the access token from the admin page so it is stored encrypted.
With OrchardCore.Workflows enabled, the Meta Conversions API Event task
(category Meta) sends a server-side event when a workflow runs:
- Event Name, for example
PurchaseorLead(supports workflow expressions). - Event Source URL, optional (supports expressions).
- Action Source, for example
Website,App, orEmail. - Event ID, optional, to deduplicate with the same browser-side pixel event (supports expressions).
The task has Done and Failed outcomes. Server-side events are useful for
background processes and for events affected by ad blockers.
Upgrading from 3.x
- Rename the
OrchardCore_Facebookconfiguration section toOrchardCore:Facebook(the old name still works but is deprecated). - A plain
AppSecretfrom configuration is now honored; in 3.x it had to be an already-protected value and was otherwise ignored. It logsLegacySecretConfiguration; move it to a secret. - Saved app secrets keep working. Code reading
FacebookSettings.AppSecretdirectly must also honorAppSecretSecretName. - Editing
FacebookPluginPartcontent now requiresManageLiquidTemplates. Permission.Descriptionvalues areLocalizationSource; seeorchardcore-permission-providers.