Skip to main content

Configuration

The configuration detailed here is utilized by both the <ConsentManager /> component in Core and the <ConsentManagerDefaultInterface /> component in our default interface.

PropertyTypeDescription
integrationsIntegrationConfig[]Array of configurations for each integration.
onChangeDecisionFunctionOptional callback that triggers when a consent decision changes.

Setting Up Integrations

Utilizing Pre-built Integrations

For ease and efficiency, you can leverage existing integrations in Consent Manager. These integrations come pre-configured and are ready to use with minimal setup, as demonstrated below:

import { matomoIntegration } from '@consent-manager/integration-matomo'

const consentManagerConfig = {
integrations: [
matomoIntegration({
matomoURL: 'https://statistics.yourdomain.com/',
siteID: 'YOUR_SITE_ID',
}),
],
}

Create your own integration

Alternatively, you can create a custom integration tailored to your specific needs.

IntegrationConfig Structure

Each integration used within the ConsentManagerConfig must conform to the following structure:

PropertyTypeDescription
idstringUnique identifier for the integration.
titlestringThe title of the integration.
descriptionstringA brief description of the integration.
categorystringThe category under which the integration falls.
colorstringOptional. The primary color associated with the integration.
contrastColorstringOptional. A contrasting color for better visibility.
privacyPolicyUrlstringURL to the privacy policy of the integration.
IconReact.FCA React component for the integration's icon.
pageViewEventHandlerPageViewEventTriggerOptional. Handler for tracking page views.
WrapperComponentReact.FCOptional. A wrapper component for the integration.
optionsIntegrationConfigOptionsOptional. Additional configuration options for the integration.
enabledByDefaultbooleanOptional. Indicates if the integration is enabled by default.

Here’s an example of how you might configure the Consent Manager in your application:

import { ConsentManager } from '@consent-manager/core'
import { matomoIntegration } from '@consent-manager/integration-matomo'
import { yourCustomIntegration } from './your-integration'

const consentManagerConfig = {
integrations: [
matomoIntegration({
matomoURL: 'https://statistics.yourdomain.com/',
siteID: 'YOUR_SITE_ID',
}),
yourCustomIntegration({
tracking_key: 'VERY#SECURE#KEY',
}),
],
onChangeDecision: (lastDecisionsState, nextDecisionState) => {
// Handle decision changes as you wish
},
}

const App = () => {
return (
<ConsentManager config={consentManagerConfig}>
{/* Your application components */}
</ConsentManager>
)
}