Managing Visitor Consent
//... 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
visitor.setConsent(true);
import React from "react";
import { FlagshipProvider, useFlagship } from "@flagship.io/react-sdk";
const App = () => (
<>
<FlagshipProvider
envId="<ENV_ID>"
apiKey="<API_KEY>"
visitorData={{
id: "<VISITOR_ID>",
hasConsented: true, //Set during the visitor creation process
context: {
isVIP: true,
country: "NL",
loginProvider: "Google"
}
}}
>
<Component/>
</FlagshipProvider>
</>
);
const Component = () => {
const { setConsent } = useFlagship();
useEffect(() => {
// Alternatively, use the setConsent method
setConsent(true);
}, []);
return (
<div>
<h1>My component</h1>
</div>
);
};Last updated
Was this helpful?

