Get started
Consent & visitor IDs
MetricRaven works without consent and connects visits across days once storage is allowed.
How visitor IDs work
Before consent: the tracker uses a server-derived visitor ID that changes daily. Nothing that identifies the visitor is stored in the browser.
With consent: it keeps a random first-party identifier for up to a year, so visits on different days are easier to connect.
Connect your cookie banner
Set stored consent before the tracker loads
If your banner already has stored analytics consent, set it before the MetricRaven script tag:
index.html<script> // Only set true when the visitor has already allowed analytics storage. window.analyticsConsent = true; </script> <!-- Your MetricRaven script tag goes after this. -->Call setConsent from your banner
Once the tracker is loaded, wire up the banner's accept and withdraw handlers:
script.js// Call these from your cookie banner's accept / withdraw handlers. window.analytics?.setConsent(true); window.analytics?.setConsent(false);
Verify it works
After accepting, window.analytics.getVisitorId() keeps returning the same ID across days in that browser. After withdrawing, the stored ID is removed.
Details
- These calls only control MetricRaven's visitor storage. They don't configure your cookie banner or other scripts.
- If the tracker isn't loaded yet,
setConsentisn't available; setwindow.analyticsConsent = truebefore loading it instead. - With consent, the identifier is kept in a first-party cookie and
localStorage. Adddata-domainto share the cookie across subdomains.