# Consent Management

While Flipbooks does have built-in cookie consent management, we understand that some may prefer to use either their own system or a 3rd party system. On this page we have gathered useful code snippets that can assist in implementing custom cookie consent solutions using the v2 Flipbook JavaScript API.

{% hint style="info" %}
**Note:**

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

{% hint style="info" %}
**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 Management 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).
{% endhint %}

## Get current cookie consent

```javascript
async function iPaperInit() {
    await iPaperAPI.getCookieConsent();
}
```

This will return an object that represents the current cookie consent given, like the example below:

```javascript
{
    allowAdvertisingCookies: true
    allowFunctionalCookies: true
    allowPerformanceCookies: true
    allowStrictlyNecessaryCookies: true
    hasPreviousCookieConsent: true
}
```

## Set/Update cookie consent

When setting/updating cookie consent, you can set whether or not (true/false) to allow 3 categories of cookies: Performance, Functional, and Advertising.

```javascript
function iPaperInit() {
    iPaperAPI.updateCookieConsent({ 
        allowPerformanceCookies: true, 
        allowFunctionalCookies: true, 
        allowAdvertisingCookies: true
    });
}
```

## Cookie consent updated callback

Using the code below you can define a callback function that will run when the cookie consent is updated/changed:

```javascript
function iPaperInit() {
    iPaperAPI.onCookieConsentUpdate = function(newConsent) {
        // YOUR CODE GOES HERE
    };
}
```

## Cookie policy callback

Using the code below you can define a callback function that runs when the “Cookie Policy” button/link in the Flipbook viewer header is clicked:

```javascript
function iPaperInit() {
    iPaperAPI.onCookieConsentShown = function() {
        // YOUR CODE GOES HERE
    }
}
```

Please note that by default clicking the “Cookie Policy” button will not do anything if the callback function has not been defined.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ipaper.io/flipbook-javascript-api/legacy-javascript-api-v2/consent-management.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
