start()— the agent-download request that retrieves the latest fingerprinting logic from our CDN and collects the necessary browser attributes. This request is not billed. It must happen before sending the identification request.get()— the identification request that sends the collected browser attributes to Fingerprint API and receives avisitor_idin return. This request is billed and counts towards your monthly quota. It can happen only afterstart()(immediately or later).
Only use the JavaScript agent where you need it
Depending on your use case, the placement of the JavaScript agent can range from all pages of your app to specific pages and events. We recommend callingget() only when the visitor_id will be used by your application. You can also choose to call get() only after the visitor gives consent to using cookies on your website.
The table below lists common use cases and recommended integration of the JavaScript agent.
Pre-connect to Fingerprint URLs
API pre-connect is recommended for improved request timings. To enable it, place thepreconnect directive as early as possible in your head tag:
- If you are using the default (US/Global) region, pre-connect to this URL:
https://api.fpjs.io - If you’re using the EU region, pre-connect to this URL instead:
https://eu.api.fpjs.io. - If you’re using the Mumbai API, pre-connect to this URL instead:
https://ap.api.fpjs.io - If you’re using the Custom subdomain or another Proxy integration on a subdomain, use the subdomain as the pre-connect URL, for example:
HTML
Preload the JavaScript agent
Generally, we recommend initializing the JavaScript agent (by callingFingerprint.start(...)) as early as possible, and requesting the visitor identifier (by calling get()) only when you need it. A good moment to start() the JavaScript agent is when your application starts.
An example of a browser application improvement:
JavaScript
visitor_id because the JavaScript agent is already loaded and the browser signals are collected before the user clicks the button.
Pre-request the visitor ID
You can decrease the time to get the visitor ID even more. You can callfp.get() a small time before you need the identifier. For example, when the visitor fills all the form fields or moves the cursor above the submit button. Getting the visitor ID will be in progress or complete when you need it. For example:
JavaScript
Cache the visitor ID
Depending on your use case, your implementation might benefit from caching the visitor ID in the browser for anything between 1 to 12 hours and only callingget() when the cache expires. See Caching visitor information for more information on caching best practices.