To initialize the CMP, you need to call the “init” command and pass it a configuration object.
The “init” command triggers the initialization logic, which includes determining if the user should be prompted for consent based on Geolocation. Any ad tag or other scripts that request consent from the CMP will be responded to after the CMP completes initialization.
The initialization process isn’t complete until the “init” call is made and the user has saved their consent preferences (if prompted). The config object has the following properties.
- Mandatory: config.uiUrl - (string) URL to the publisher hosted consent UI.
- Optional: config.gdprAppliesGlobally - (boolean) True for EU targeted sites. Defaults to false.
- Optional: config.uiDisplayMode: (string) - “iframe” renders UI in a modal iframe, “standalone” renders UI in a standalone page. Defaults to “iframe”.
- Optional: config.uiCustomParams (object) This is not used directly by the CMP JS. It provides a way for publishers to pass any additional information to the CMP UI.
To initialize the CMP, perform the following steps:
- Replace the placeholders in the configuration object (highlighted in red) with the relevant options according to the following table:
Placeholder Mandatory Description Value Example CONSENT_UI_URL
The URL address pointing to the Publisher's hosted consent User Interface.
- Full URL
uiUrl: 'https://www.example.com/cmp/cmpui.html', GEO_DISPLAY_MODE
(False by default)
Define if the consent form UI will be displayed only to EU Consumers or to All Consumers regardless of geolocation.
- false (default)= EU Only
- true = Everywhere
gdprAppliesGlobally: false, UI_DISPLAY_MODE
(iFrame mode by default)
Define how to render the consent UI in either an iFrame or in a standalone page in another browser tab.
- iframe (default)= Render in an iframe
- standalone = render in another browser tab
uiDisplayMode: iframe CONCENT_CUSTOMIZATION
This is not used directly by the CMP JS. It provides a way for publishers to pass any additional information to the CMP UI Object