Custom Consent Manager

Integrate your own consent manager with the Freshpaint Web SDK

Freshpaint supports integrating with a custom consent manager in order to ensure you are respecting your users' data privacy choices while still being able to leverage Freshpaint for sending data to your preferred marketing and advertising platforms.

Prerequisites

This guide assumes you have already set up the Freshpaint Javascript SDK and set up at least one data destination in the Freshpaint app. If not, follow these guides to get set up

Installation

There are 2 steps to integrating the Freshpaint SDK with your consent manager:

  1. Initialize Freshpaint with the default (or most recent) consent choices

  2. Set up an event listener to update the user's consent elections whenever they change

To ensure that the Freshpaint SDK loads with the default consent, we need to pass in that consent object at initialization like so:

freshpaint.init("<environment_id>", {
  "consent_management": {
    "initial_consent": {
      "All": false,
      "Mixpanel": true
    }
  }
})

The initial_consent object follows the same pattern as the Integrations Object.

Secondly, to ensure that changes to your user's consent are respected, you must set up an event listener on consent changes to update this consent object.

// if your consent manager has a built-in event listener hook
consentmanager.addEventListener("onConsentSaved", function (consentObject) {
  // add internal mapping from consent manager to freshpaint destinations here
  const fpConsentObject = mapConsentToFP(consentObject)
  freshpaint.set_consent(fpConsentObject)
})

// otherwise
window.addEventListener("onConsentSaved", function () {
  // add internal mapping from consent manager to freshpaint destinations
  const fpConsentObject = mapConsentToFP(consentmanager.getConsent())
  freshpaint.set_consent(fpConsentObject)
})

You can pass a consent object into the freshpaint.init function call to set a default/initial state for the user's consent.

To limit which destinations a user's data is sent to, set All: false to ensure user events are not sent to any destinations unless the destination is explicitly set to true.

Example:

{
  "All": false,
  "Mixpanel": true,
  "Facebook Conversions API": false
}

Last updated