visitorId generated per page view across all pages on a site can lead to unexpected and excess API usage. We recommend storing the visitorId per browser session to minimize the identifications of a visitor as they navigate your site from one browser tab.
Values stored in sessionStorage, localStorage, and cookies are not available from Incognito mode, so these caching attempts will not work if a visitor switches from normal to private browsing (or vice versa).
sessionStorage is one solution to cache the FingerprintJS
visitorId per user session. Unlike localStorage, this property is automatically cleared when the page session ends (i.e. closing the browser tab or window).
First, perform a check whether sessionStorage contains a
visitorId by wrapping an if statement around
visitorId does not exist (condition is false), perform a FingerprintJS API request using the
fp.get() method. When the promise is resolved, write the
visitorId to sessionStorage.
Learn more about sessionStorage here: https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
visitorId is performed, and if the cookie does not exist only then is a request made to FingerprintJS. The difference is that cookies require an expiration date defined by the developer. We recommend storing a visitorId no longer than 24 hours.
Learn more about cookies here: https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie
If you are using FingerprintJS in a single-page application built with frameworks like React, Vue, or Angular, we recommend using the official SPA wrapper available on GitHub. This library offers caching options for sessionStorage or localStorage.
If you are looking for a dedicated React wrapper, you can find it on GitHub here: https://github.com/fingerprintjs/fingerprintjs-pro-react
For high identification accuracy, we recommend caching the
visitorIdfor no longer than 24 hours.
Updated 4 months ago