A client-side library to help you add a CMP (currently provided by Sourcepoint) to your application.
Install as a <script> tag (recommended):
<script async src="https://consent-notice.ft.com/cmp.js"></script>
Install the library from NPM:
npm install @financial-times/cmp-client
The src
attribute of the script
tag points to an immediately invoked function expression (IIFE) that sets up the CMP client on the host page. When the CMP client is installed this way, no additional work needs to be done.
The primary benefit of using this integration method is that your users will automatically get new updates to the CMP client as soon as they are available, as opposed to requiring a version bump and application release. However, for this method to work successfully, the host page must be one of our registered properties. Please reach out to the Ads & Privacy team if you are not sure or you would like to register a property.
By default the source link integrates the latest version of the CMP client. If you would like to pin a different version, you can append a version
query parameter to the source link as follows:
<script async src="https://consent-notice.ft.com/cmp.js?version=4.0.0"></script>
[!Note] We will be adding new properties (i.e. websites under FT group) and their configs as we start rolling out.
Please reach out to the Ads & Privacy team if you think your domain needs a new property config
import {
initSourcepointCmp,
properties,
interceptManageCookiesLinks,
debug,
} from "@financial-times/cmp-client";
/**
* Optionally enable debug mode to see CMP events in the console
*/
debug.logCmpEvents();
/**
* Import your domain's CMP configuration from the `properties` module:
* e.g. properties.MM_IGNITES_ASIA, properties.SP_THE_BANKER, etc.
*
* We will add more domains as we create new properties in Sourcepoint
*
* See below for the full list of initialisation options
*/
initSourcepointCmp({
propertyConfig: properties["YOUR_PROPERTY_CONFIG_KEY"],
useConsentStore: false, // Specialist Titles _must_ opt out of Single Consent Store
});
/**
* Optionally enable "Manage Cookies" link util
*/
interceptManageCookiesLinks(properties["YOUR_PROPERTY_CONFIG_KEY"]);
import {
initSourcepointCmp,
properties,
interceptManageCookiesLinks,
debug,
} from "@financial-times/cmp-client";
/**
* Optionally enable debug mode to see CMP events in the console
*/
debug.logCmpEvents();
/**
* We suggest using a feature flag to disable the existing cookie banner
* and enable the new one
*/
if (flagsClient.get("adsDisableInternalCMP")) {
initSourcepointCmp({
propertyConfig: FT_DOTCOM_TEST,
});
interceptManageCookiesLinks();
}
Option | Description |
---|---|
propertyConfig (SourcepointConfig) |
This config object is directly passed to Sourcepoint (our external CMP) and presets (imported like example usage) will be made available for different properties/titles under the FT group. This currently defaults to the FT_DOTCOM_PROD preset |
userId (string) |
Please provide a userId if the user is a logged in user. If your app uses the FT Secure Session token, you can leave empty and set useFTSession to true instead. Defaults to undefined for anonymous users |
useFTSession (boolean) |
Set this flag if you want the user's Id to be automatically derived from their FT Secure Session. Set to false if your app doesn't use FT Secure Session. Defaults to true
|
consentProxyHost (string) |
The fully qualified domain name for your consent proxy instance e.g https://consent.thebanker.com . Defaults to https://consent.ft.com
|
cookieDomain (string) |
The domain (and subdomains) that the FTConsent cookie will apply to e.g .thebanker.com . Defaults to .ft.com
|
formOfWordsId (string) |
The IAB custom categories that you have adapted might be tracked under a different FOW ID. At the moment, all custom categories are tracked under the sourcepointCmp form-of-words and it defaults to sourcepointCmp/VngD.XycZut.595cp9fWdp5XYP9vlFvk . Properties using the consent banner as presented should use the default value |
useConsentStore (boolean) |
Specifies whether the user's consent record should also be backed by the Single Consent Store. Properties like Specialist titles will need to explicitly set this to false as true is the default behavior |
disableFTCookies (boolean) |
Specifies whether the user's consent record should be saved to FT Cookies. Properties like Specialist titles that don't utilize FT cookies will need to explicitly set this to true as false is the default behavior |
events (object) |
Used internally to define handlers for events emitted by the Vendor-supplied CMP module. See notes on "Responding to CMP events" below for details on how to define custom event handlers |
Property Key | Details |
---|---|
FT_DOTCOM_TEST |
Use this configuration preset for testing the CMP on a property that has not yet been registered in the Sourcepoint portal. All |
FT_DOTCOM_PROD |
Configuration preset for all properties on FT.com domain operating in a production environment - https://*.ft.com
|
SP_THE_BANKER |
Configuration preset for properties on thebanker.com domain |
SP_PWMNET |
Configuration preset for properties on pwmnet.com domain |
SP_FDI_INTELLIGENCE |
Configuration preset for properties on fdiintelligence.com domain |
SP_BANKING_RR |
Configuration preset for properties on bankingriskandregulation.com domain |
SP_SUSTAINABLE_VIEWS |
Configuration preset for properties on sustainableviews.com domain |
SP_FT_ADVISER |
Configuration preset for properties on ftadviser.com domain |
SP_INVESTORS_CHRONICLE |
Configuration preset for properties on investorschronicle.co.uk domain |
MM_IGNITES_ASIA |
Configuration preset for properties on ignitesasia.com domain |
MM_IGNITES_EUROPE |
Configuration preset for properties on igniteseurope.com domain |
If you need to do additional work in response to events emitted by the CMP Vendor module – e.g. initialising vendor packages that match the purposes granted by the user – you can do so via the window._sp_.addEventListener
method:
window._sp_.addEventListener("onMessageReady", (messageType) => {... });
window._sp_.addEventListener("onConsentReady", (legislation, consentUUID, consentString, consentMeta) => { ... });
[!Note] The
onConsentReady
event is fired
- As soon as the CMP has finished loading and the user's consent choices are available
- Subsequently, whenever the user's consent choices change
See the Sourcepoint docs for a full listing of the events you can listen for and the arguments passed to the callbacks.
You can verify that the CMP is correctly configured using the logCmpEvents
method exported from the debug
module:
import { debug } from "@financial-times/cmp-client";
debug.logCmpEvents();
If everything's working then you'll see the CMP Module log its lifecycle events to the console, even if its UI isn't displayed.
This can easily happen when you've made a previous consent choice and the CMP is now picking it up from local storage. For this reason we recommend running in an incognito window during development.
[!Note] Please ensure that your app always uses the latest version of the CMP Client library.
You can check the version your live app is using by running the following in the browser console:
window.FT_CMP_CLIENT_VERSION
If you have access to the source on Github you can take a look at the reference implementations in src/examples/cmp-client
.
To see a demo in action in your browser, run:
npm run dev -w src/examples/cmp-client
Visit https://localhost:5173 (see setup details in src/examples/cmp-client
) to interact with the banner and see how cookies are set accordingly
For resetting your consent cookies/record and other common troubleshooting issues, see the Troubleshooting Guide
For a detailed deep-dive (internal only) of how the static deployment process works, the design is documented here. If you need to be granted access, please reach out to the Ads & Privacy team.