Tracking Data
import { HitType, EventCategory } from "@flagship.io/js-sdk";
// ... other code
visitor.sendHit({
type: HitType.EVENT,
category: EventCategory.USER_ENGAGEMENT,
action: "click",
label: "label",
value: 100,
});import React from "react";
import { FlagshipProvider, useFlagship, HitType, EventCategory } from "@flagship.io/react-sdk";
const App = () => (
<>
<FlagshipProvider
envId="<ENV_ID>"
apiKey="<API_KEY>"
visitorData={{
id: "<VISITOR_ID>",
hasConsented: true,
context: {
isVIP: true,
}
}}
>
<Component/>
</FlagshipProvider>
</>
);
const Component = () => {
const { sendHit } = useFlagship();
return (
<div>
<h1>My component</h1>
<button onClick={() =>{
sendHit({
type: HitType.EVENT,
category: EventCategory.USER_ENGAGEMENT,
action: "click",
label: "label",
value: 100,
});
}}>
Send event</button>
</div>
);
};SDK
Last updated
Was this helpful?

