While the implementations below work as intended during the time of writing, we unfortunately cannot guarantee that they will always work for you as-is. Since this is not an official integration with Cookiebot, changes they make to their code base may also have an impact on the snippets below.
Note:
The snippets below are all intended to be used through the Custom Scripting module. If you wish to use them with the Flipbook JavaScript API instead they will require some adjustment.
Before inserting new <script> tags in Custom Scripting containing these snippets, you should ensure that you have loaded the script(s) for Cookiebot first (be aware that loading these async can cause issues).
Setting and updating iPaper Consent
This snippet is an example of how you can set the iPaper consent to be equal to that of Cookiebot.
First, we need to instantiate a new iPaper API instance (if this has not been done already) which we can then use to access the Consent Management methods/functions:
constinstance=iPaperJsApi(3);
First, we need to introduce a function that will retrieve the current consent from Cookiebot, and then update the iPaper consent, so it matches:
functionsetIpaperConsent() {// Get consent for each category/* By default, the below will be the names for the categories. However, dependent on your specific set-up, these can have custom names instead */constallowPerformanceCookies=Cookiebot.consent.statistics ?true:false;constallowFunctionalCookies=Cookiebot.consent.preferences ?true:false;constallowAdvertisingCookies=Cookiebot.consent.marketing ?true:false;// Set iPaper consent to match the aboveinstance.consent.set({ allowPerformanceCookies, allowFunctionalCookies, allowAdvertisingCookies });}
Next up, we need to ensure that the setIpaperConsent() function will be run in two cases:
When the page initializes/loads
When the user changes their consent via the Cookiebot banner
// Listen for changes to Cookiebot consent and update iPaper consent accordinglywindow.addEventListener('CookiebotOnConsentReady', () =>setIpaperConsent());iPaper.API.consent.onShow(() => {Cookiebot.show();});
And that's it!
With the full snippet (see below), the iPaper consent will now be set and updated, so it matches what your users set in the Cookiebot banner.
<script id="Cookiebot" src="https://consent.cookiebot.com/uc.js" data-cbid="YOUR UNIQE COOKIEBOT CBID" type="text/javascript" async></script>
<script>// Instantiate new API instanceconstinstance=iPaperJsApi(3);// Sets the iPaper consent to match the current Cookiebot consentfunctionsetIpaperConsent() {// Get consent for each category/* By default, the below will be the names for the categories. However, dependent on your specific set-up, these can have custom names instead */constallowPerformanceCookies=Cookiebot.consent.statistics ?true:false;constallowFunctionalCookies=Cookiebot.consent.preferences ?true:false;constallowAdvertisingCookies=Cookiebot.consent.marketing ?true:false;// Set iPaper consent to match the aboveinstance.consent.set({ allowPerformanceCookies, allowFunctionalCookies, allowAdvertisingCookies });}// Listen for changes to Cookiebot consent and update iPaper consent accordinglywindow.addEventListener('CookiebotOnConsentReady', () =>setIpaperConsent());instance.consent.onShow(() => {Cookiebot.show();});</script>
Showing the cookie banner
First, we need to instantiate a new iPaper API instance (if this has not been done already) which we can then use to access the Consent Management methods/functions:
constinstance=iPaperJsApi(3);
To show the Cookiebot banner when the "Cookie Policy" link in the top bar menu has been clicked, you can set up an onShow subscription like in the snippet below: