@platformd/analytics
v0.1.0
Published
Typed browser analytics for applications hosted by platformd
Readme
@platformd/analytics
Typed browser analytics for applications hosted by platformd.
import { createAnalytics } from "@platformd/analytics";
type Events = {
checkout_completed: {
currency: string;
orderId: string;
revenue: number;
};
};
export const analytics = createAnalytics<Events>({
cookieDomain: ".example.com",
mode: "opt-out",
});
analytics.track("checkout_completed", {
currency: "USD",
orderId: "order-1",
revenue: 49.99,
});Initialize the client once in the browser entry module. It automatically records page views, SPA navigation, page leave, click heatmaps, and scroll heatmaps.
For opt-in trackers, call analytics.consent("granted") after the visitor accepts analytics. Calling analytics.consent("denied") removes the anonymous and session cookies. Global Privacy Control is always respected.
