@plexusone/analytics¶
Counts page views through PostHog's EU cloud, storing nothing in the browser. It needs no React, so it works on marketing sites as well as applications.
Installation¶
Usage¶
import { startAnalytics } from '@plexusone/analytics';
startAnalytics({
site: 'example',
host: 'example.com',
key: import.meta.env.PUBLIC_POSTHOG_KEY,
});
| Option | Meaning |
|---|---|
site |
The site's name, sent with every event |
host |
The live host. Any other host, such as a preview, sends nothing |
key |
The PostHog project's public key. Without one, nothing is sent |
Counting Page Views is the step-by-step guide.
Turn on cookieless server hash mode in the PostHog project, which the cookieless events need.
Privacy¶
The settings are fixed, so no site can loosen them by accident:
- no cookies and no browser storage: PostHog's client tests whether local storage works by writing a value and removing it, and leaves nothing;
- one page view for each load, and nothing else: no autocapture, session recording, surveys, heatmaps or page-leave events;
- no person profiles;
- no further scripts loaded, and no request for feature flags or settings;
- its own PostHog instance, so another use of PostHog on the page neither changes these settings nor receives its page views;
- a browser that asks not to be tracked (Do Not Track or Global Privacy Control) sends nothing, and does not load PostHog's client.
A page view includes the page's address. Don't put secrets or personal data in the query string of a page that counts views, and don't use the package on pages for children.
Product events are sent from the server, by SystemForge's analytics package.