Skip to main content

Compliance and consent

The Uniform tracker handles visitor classification, but the tracker requires the developer to indicate that the visitor has provided their consent to be tracked. This section describes how to use this functionality.


For more information about the components involved with visitor tracking, see the documentation for the @uniformdev/context package.

The following example creates a button that you can add to an application that the visitor can click in order to provide their consent.

import { Context } from '@uniformdev/context';
import React from 'react';

const context = new Context({
manifest: { project: {} },
defaultConsent: false, // Disable consent until user grants consent

export function CookieConsentPattern() {
const handleConsentToggleClick = (e) => {

const newValue = !;[{
type: 'consent',
data: newValue
alert(`Storage consent is now ${newValue}`);

return (
Cookie consent example
<button onClick={handleConsentToggleClick}>Toggle Consent</button>

The Uniform Context object handles tracking. When this object is initialized, you can specify whether consent has been granted. During development and testing, when an external visitor is not involved, it can be convenient to disable the requirement that the visitor provide their consent.

const context = new Context({
manifest: { project: {} },
defaultConsent: true,