Consent

Through the JS API, you can manage the cookie consent set for the flipbook. This is particularly useful if you want to implement your own cookie solution or a 3rd party one.

Note:

Prior to implementing custom cookie solutions, please make sure that your Flipbook cookie policy is set to ‘Integration’.

Note:

When using a 3rd party cookie solution, please make sure that the scripts for the solution are fully loaded before you reference it/use it inside any of the consent API methods. In order to avoid issues, we also recommend that you do not load the 3rd party script asynchronously (i.e. using the async keyword in the tag).

Commands

get

Retrieves the active/current cookie consent of a Flipbook.

// You can either await the result of the command
const result = await instance.consent.get();

// OR pass a callback
instance.consent.get((result) => {
    // YOUR CODE HERE
});

The command will return an object with the following properties:

Property
Type
Description

allowPerformanceCookies

boolean

Are performance cookies enabled/allowed

allowFunctionalCookies

boolean

Are functional cookies enabled/allowed

allowAdvertisingCookies

boolean

Are advertising cookies enabled/allowed

allowStrictlyNecessaryCookies

boolean

Are strictly necessary cookies enabled/allowed (always true)

hasPreviousCookieConsent

boolean

Has user previously given explicit consent

set

This command allows you to set/update the cookie consent for a flipbook. The command requires one argument, consisting of the properties below:

Property
Type
Description

allowPerformanceCookies

boolean

Should performance cookies be allowed

allowFunctionalCookies

boolean

Should functional cookies be allowed

allowAdvertisingCookies

boolean

Should advertising cookies be allowed

instance.consent.set({
    allowPerformanceCookies: true, 
    allowFunctionalCookies: true, 
    allowAdvertisingCookies: true
});

Optionally, you can add a callback to this command which will run once the consent has been sucesfully updated:

function consentUpdated(result){
    // YOUR CODE HERE
};

instance.consent.set({
    allowPerformanceCookies: true, 
    allowFunctionalCookies: true, 
    allowAdvertisingCookies: true
}, consentUpdated);

The callback contains a value/result of what the cookie consent was sucessfully updated to:

Property
Type
Description

allowPerformanceCookies

boolean

Are performance cookies enabled/allowed

allowFunctionalCookies

boolean

Are functional cookies enabled/allowed

allowAdvertisingCookies

boolean

Are advertising cookies enabled/allowed

allowStrictlyNecessaryCookies

boolean

Are strictly necessary cookies enabled/allowed (always true)

hasPreviousCookieConsent

boolean

Has user previously given explicit consent

show

If you are using iPaper's built-in basic cookie banner, you can toggle the banner to be shown via this command.

instance.consent.show();

Events

onChange

This subscription will trigger every time the cookie consent is changed/updated.

instance.consent.onChange((result) => {
    // YOUR CODE HERE
});

The callback contains a value/result with the following properties:

Property
Type
Description

allowPerformanceCookies

boolean

Are performance cookies enabled/allowed

allowFunctionalCookies

boolean

Are functional cookies enabled/allowed

allowAdvertisingCookies

boolean

Are advertising cookies enabled/allowed

allowStrictlyNecessaryCookies

boolean

Are strictly necessary cookies enabled/allowed (always true)

hasPreviousCookieConsent

boolean

Has user previously given explicit consent

onShow

By listening to this event you can define a callback function that runs when either the show API command has been run, or when the “Cookie Policy” button/link in the Flipbook viewer header is clicked. This could for example be used to trigger showing a 3rd party cookie banner.

instance.consent.onShow(() => {
    // YOUR CODE HERE
});

Last updated