Creating a Visitor
Within the Flagship SDK
, a visitor represents an individual user of your application. Each visitor is identified by a unique ID, which allows Flagship to track their interactions and deliver personalized experiences based on their context.
By creating a visitor instance, you will be able to set all relevant data for Flagship to take a Decision. These data include : Visitor ID , Visitor Context , GDPR Consent , and Authenticated or not.
Below are examples in different programming environments:
// ...import code
Flagship.start("<ENV_ID>", "<API_KEY>");
const fsVisitor = Flagship.newVisitor({
visitorId: "<VISITOR_ID>",
hasConsented: true,
context: {
isVIP: true,
country: "NL",
loginProvider: "Google"
}
});
import React from "react";
import { FlagshipProvider } from "@flagship.io/react-sdk";
const App = () => (
<>
<FlagshipProvider
envId="<ENV_ID>"
apiKey="<API_KEY>"
visitorData={{
id: "<VISITOR_ID>",
hasConsented: true, // This is required
context: {
isVIP: true,
country: "NL",
loginProvider: "Google"
}
}}
>
{/* ... */}
</FlagshipProvider>
</>
);
import React from "react";
import { FlagshipProvider } from "@flagship.io/react-native-sdk";
const App = () => (
<>
<FlagshipProvider
envId="<ENV_ID>"
apiKey="<API_KEY>"
visitorData={{
id: "<VISITOR_ID>",
hasConsented: true, // This is required
context: {
isVIP: true,
country: "NL",
loginProvider: "Google"
}
}}
>
{/* ... */}
</FlagshipProvider>
</>
);
require __DIR__ . '/vendor/autoload.php';
use Flagship\Flagship;
// ...other code
$visitor = Flagship::newVisitor("<VISITOR_ID>", true)
->setContext([
"isVip" => true,
"country": "NL",
"loginProvider": "Google"
])->build();
using Flagship.Main;
// ...other code
var visitor = Fs.NewVisitor("<VISITOR_ID>", true)
.SetContext(new Dictionary<string, object> {
{ "isQA", true },
{ "country", "NL" },
{ "loginProvider", "Google" }
})
.Build();
// ...other code
Information
You should make sure that you have already started the sdk before creating any visitor.
Please consult the reference documentation of newVisitor
for your specific SDK for more detailed information:
Updated 4 months ago