PubConsent

Web Standard Integration

6min

Once you've opened and configured your CMP, in the integration tab, you'll find instructions to add PubConsent CMP to your site in just a few simple clicks.

Tab integrazione configuratore PubCosent
Tab integrazione configuratore PubCosent


For integration, make sure to follow the instructions and do not modify the integration code provided in the panel, as the integration code ensures cross-browser support of the CMP and performance improvements specific to the user's browser.

Be careful to avoid duplicates of the CMP script tag.

To offer users a better experience, we recommend placing the CMP script tag inside the tag and as close to the top as possible.

Follow our Performance tips to improve integration and the experience of your users.

In addition to the integration code of the JS code, you can configure a callback that is executed when a user gives or changes consent.

An example is provided below:

HTML


Please note that the CCPA version will be available soon.

In the "onConsent" callback shown in the example, there are 3 input parameters:

  1. consentData: An object that always contains the "privacyLaw" field, which can be 'TCF-V2-GDPR' or 'GOOGLE-CONSENT-MODE'. When the version is GDPR, it also contains tcString, acString, and pcString, while when the version is GOOGLE-CONSENT-MODE, it contains things relative to the Google Consent Mode. These strings represent the current state of the user's choices for each privacy law (later the field will be changed to cmpType since it's more appropriate).
  2. consentObject: An object that contains additional information about consent. When the privacy law is GDPR, there is information related to the IAB framework, while when it is GOOGLE-CONSENT-MODE, there is information related to GCM V2.
  3. publisherConsentObject: An object that contains information about the user's choices regarding cookies (information not belonging to the IAB framework). Currently available only when GDPR privacy law applies to the user.

Most publishers use the consentObject to verify the possibility of serving advertisements. Below is an example of a configuration with specific logic to check if certain IAB purposes have been accepted by the user.

JS


If purposeRequired is true, then the user has accepted all 11 purposes with the specified IDs. Additionally, as shown with the parameter publisherConsentObject, you can check for other types of cookies that are not related to advertising. The complete list of purposes is available here.

Be careful to avoid duplicates of the CMP script tag.

Technical cookies are always enabled by definition, so you don't need to check any flag.

Once the integration is complete, make sure to block third-party codes from using the cookies you have configured, following the tutorial.

Integrate Google Consent Mode V2

The integration of Google Consent Mode V2 can be done through one of the two available integrations: