Skip to main content
The JavaScript agent is a client-side JavaScript agent that collects browser attributes and sends them to Fingerprint servers for processing and identification. Using the JavaScript agent requires at least two HTTP requests:
  • 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 a visitor_id in return. This request is billed and counts towards your monthly quota. It can happen only after start() (immediately or later).
By optimizing these requests and timing them right, you can make visitor identification both faster and more cost-effective.

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 calling get() 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 the preconnect directive as early as possible in your head tag:
Pay attention to the URLs you need to pre-connect to:
  • 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 calling Fingerprint.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
This decreases the time of getting the visitor_id because the JavaScript agent is already loaded and the browser signals are collected before the user clicks the button.
Starting the JavaScript agent is freeDon’t worry, the agent start() call is not billed, only the identification get request counts towards your monthly plan.

Pre-request the visitor ID

You can decrease the time to get the visitor ID even more. You can call fp.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 calling get() when the cache expires. See Caching visitor information for more information on caching best practices.