setUiMode
Functionality
AdConsent can be shown to the users in four main presentations for the GDPR CMP: popup, banner, full-screen (desktop devices), and AMP (full-screen for mobile AMP devices). While popup is the default presentation for the CMP, a full-screen presentation may be better for, e.g., mobile devices, or a banner mode for a different kind of visual integration with the page. These kinds of changes in the CMP GUI can be made by using the setUiMode
function which is available under the GDPR adconsent.gdpr()
API.
Syntax
function adconsent.gdpr()
argument name | type | optional | value | description |
---|---|---|---|---|
command | string |
|
|
|
parameter | integer |
|
| 0 - popup, 1 - banner, 2 - fullscreen, 3 - AMP |
callback | function | ✔️ |
| The callback function that is called with the function call result. |
Description
The CMP for GDPR shows up in popup mode by default. This is mode 0
. Its general appearance is as shown below:
A banner mode appearance (mode 1) is shown below. To accomplish such a presentation, one needs to configure AdConsent using setUiMode
function with value 1
.
The image below shows the full-screen mode appearance (mode 2). For this mode to be shown, setUiMode
configuration should be set with value 2
in AdConsent.
This last image shows the full-screen mode appearance in AMP mobile devices (mode 3). This mode is the default one in AMP pages.
Please visit https://demo.adconsent.snigel.com/?GDPR=true to see the various AdConsent presentation modes running in a live page.
Scope
The function must be called before AdConsent shows the GUI. Calls after AdConsent has shown the GUI will only take effect if the CMP is closed and then opened again.
Example
Setting the GDPR CMP to show in banner mode
adconsent.gdpr('setUiMode', 1);
Setting the GDPR CMP to show in full-screen mode
adconsent.gdpr('setUiMode', 2);