UserCentrics
Setting and updating iPaper Consent
const instance = iPaperJsApi(3);function setIpaperConsent() {
// First, let's get all services in UserCentrics where the name includes "iPaper"
const allServices = UC_UI.getServicesBaseInfo();
const iPaperServices = allServices.filter(service => service.name.includes('iPaper'));
/*
NOTE:
Dependent on your UserCentrics set-up, some of the services may be in
custom categories. The best way to check what you will need to filter for
to find the correct service, is to console.log out iPaperServices and look
at the categorySlug property
In this example implementation, we will assume that the "Performance"
category is custom and use a variable for storing its' categorySlug
*/
const customPerformanceCategorySlug = {{ INSERT VALUE HERE }}; // Typically looks like 'customCategory-d0fe7968-5445-46a0-bc8d-c197dfa06c1c'
/*
Let's filter iPaperServices by categorySlug in order to find the cookie
category we're interested in checking the consent status of. Once we have
done that, we can access the consent status with .consent.status
*/
const allowFunctionalCookies = iPaperServices.filter(service => service.categorySlug === 'essential')[0].consent.status;
const allowPerformanceCookies = iPaperServices.filter(service => service.categorySlug === customPerformanceCategorySlug)[0].consent.status;
const allowAdvertisingCookies = iPaperServices.filter(service => service.categorySlug === 'marketing')[0].consent.status;
// Finally, we use the iPaper API to update the iPaper consent
instance.consent.set({
allowPerformanceCookies,
allowFunctionalCookies,
allowAdvertisingCookies
});
}Showing the cookie banner
Last updated