Here, the component Button will return a button that will send an event to your dashboard whenever a user double-clicks it.
Available hooks
| Hook| Utility |
|--|--|
| useClick | Tracks when a user clicks an element |
| useDoubleClick |Tracks when a user double-clicks an element|
| useScroll| Tracks when a user is scroll inside a div |
| useSubmit| Tracks when a user is submit a form |
Custom hooks
Perhaps an event you would want to track is not listed among the hooks the ratflow-react-sdk library provides, if that is your case, you can create your own custom hook to track your own event.
Each hook are actually wrapping another hook, useGenericTracker, so you would simply do what we already did.
Basic example of the source code of useClickTracker:
import { UseTrackerProps } from "../interfaces/tracker";
import useGenericTracker from "./use-generic-tracker";
In some case, you might want to send your own extra custom data, you can then provide a callback function to useGenericTracker. This callback will allow you to receive the event data and process it to return what interests you.
Example of callback with useScrollTracker:
import { UseTrackerProps } from "../interfaces/tracker";
import useGenericTracker from "./use-generic-tracker";
export default function useScrollTracker({ tag }: UseTrackerProps) {
You can get the tags variable in your Ratflow dashboard when managing your app tags.
Inside your main.tsx or main.ts file:
import { sdkConfig } from "./ratflow";
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
);
Routing
If you are using a routing library such as react-router-dom, you can increase the precision of the sdk by providing to the context what is the current page using a function returned by the context.