> For the complete documentation index, see [llms.txt](https://docs.ipaper.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ipaper.io/flipbook-javascript-api/legacy-javascript-api-v2/consent-management.md).

# Consent Management

Implement your own cookie consent solution for your Flipbook.

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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
