CMP Client
A client-side library to help you add a CMP (currently provided by Sourcepoint) to your application.
Installation
Install as a <script> tag (recommended):
<script async src="https://consent-notice.ft.com/cmp.js"></script>
To enable development branch previews (recommended), set the script referrer policy as follows:
<script async src="https://consent-notice.ft.com/cmp.js" referrerpolicy="no-referrer-when-downgrade"></script>
Install the library from NPM:
npm install @financial-times/cmp-client
Using the script tag
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>
Using the NPM package
[!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
Usage on non-FT.com properties
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"]);
Usage on FT.com
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();
}
Opening the privacy manager
Use openPrivacyManager to open the applicable privacy manager without navigating
to the FT.com preferences page:
import { initSourcepointCmp, openPrivacyManager, properties } from "@financial-times/cmp-client";
initSourcepointCmp({ propertyConfig: properties.FT_DOTCOM_PROD });
manageCookiesButton.addEventListener("click", () => {
openPrivacyManager();
});
When CMP client is loaded as a static script, use the function exposed on
window.FTConsent:
window.FTConsent.cmp.openPrivacyManager();
The function uses the property configuration passed to initSourcepointCmp and
waits for Sourcepoint to report the applicable legislation before opening the
privacy manager. It does not open while Sourcepoint is waiting for user interaction
and ignores further calls while the privacy manager is already opening or visible.
CMP configuration options:
| 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 |
SP_MANDATE_WIRE |
Configuration preset for properties on mandatewire.com domain |
SP_FT_LOCATIONS |
Configuration preset for properties on ftlocations.com domain |
