Managing Visitor Consent

In the Flagship SDK, visitor consent is the permission given by a user (visitor) to allow the application to track their interactions and use their data for personalization and analytics purposes.

Visitor consent is crucial for compliance with data privacy regulations like the General Data Protection Regulation (GDPR). These regulations require businesses to obtain explicit consent from users before collecting or processing their personal data.

Flagship SDKs provide mechanisms to manage visitor consent, allowing you to control whether data is collected or not based on the user's consent status. This ensures that your application respects user privacy and complies with relevant data protection laws.

Visitor consent is required for each visitor and can be set during the visitor creation or whenever with the visitor instance.

Below are examples in different programming environments:

//... code

//Set during the visitor creation process
const visitor = Flagship.newVisitor({
  visitorId: "your_visitor_id",
  hasConsented: true, // set hasConsented to true
  context: { isVip: true },

// Alternatively, use the setConsent method

import React from "react";
import { FlagshipProvider, useFlagship } from "";

const App = () => (
        id: "<VISITOR_ID>",
        hasConsented: true, //Set during the visitor creation process
          context: {
            isVIP: true,
            country: "NL",
            loginProvider: "Google"

const Component = () => {
  const { setConsent } = useFlagship();

  useEffect(() => {
    // Alternatively, use the setConsent method
  }, []);

  return (
      <h1>My component</h1>

use Flagship\Flagship;

//... code

//Set during the visitor creation process
$visitor = Flagship::newVisitor("<VISITOR_ID>", true)
        ->setContext(["isVip" => true])

// Alternatively, use the setConsent method



When a visitor sets consent to false, the data collection features (visitorExposed and sendHit) will be deactivated for them and all hits related to the visitor will be flushed from the pool and the cache.