#Installation

The Audit.js script is a hosted script that, in conjunction with Access.js, will allow to track a few more events regarding your site.
It is required when planing to use native segmentation.
Historically, this was automatically done by the poool() method alongside creating a new paywall. In order to be able to display a paywall without using native segmentation, the Audit.js script is now a standalone entity.

#Load the script

Like Access.js, the Audit.js script can be loaded in a lot of different ways.
We will purposely not cover the React implementation here as we already manage everything automatically for you in @poool/react-access.

ℹ️ If you are using Content Security Policies on your site, make sure to add https://*.poool.fr (or the api, assets and cdn subdomains if you are not comfortable with wildcards) to your whitelist in order for the script to operate normally.

While sync mode is easier to read and use, we recommend using async mode to avoid any unwanted side effects to your browser when the script is loading.

#Use both Audit.js and Access.js

Audit.js has been created as a sister library to Access.js and will thus be automatically detected by Access.js in your page. Access.js will wait for Audit.js to be ready to ensure they both use the same user identifier.
However, if you hate magic and like to do things your own way, you can disable the default behavior using Access' skip_audit_loader configuration option and manually listen for Audit's identityAvailable event.

#Retrieve user consent

As part of the latest regulations in Europe regarding user consent, you have to provide the information to Audit.js that the visitor explicitly consented to allow the _poool cookie to exist in order to allow the tracking to operate normally.
This is done through the cookies_enabled configuration key.
Depending on your Consent Management Platform provider, the method to retrieve the consent might differ. Here are a few examples:

Now that everything is set up, you can look out for the right configuration that fits your needs.