Impression
Tracks impression events using the Intersection Observer API.
import { createTracker } from "@offlegacy/event-tracker";
const [Track] = createTracker({
impression: {
onImpression: (params, context) => {
// Handle impression event
},
options: {
threshold: 0.5,
},
},
});
function App() {
return (
<Track.Provider initialContext={{}}>
<Track.Impression params={{ elementId: "hero" }} options={{ threshold: 0.8 }}>
<div>Tracked content</div>
</Track.Impression>
</Track.Provider>
);
}
Props
options?: ImpressionOptions
- Optional configuration (overrides global options)- With schema
params: SchemaParams | (context: Context) => SchemaParams
- Impression event parameters based on schemaschema: string
- A name of schema that will be used to validate the event parameters
- Without schema
params: EventParams | (context: Context) => EventParams
- Impression event parameters
Last updated on