start() function or its equivalent in your frontend library. The function is exported from the @fingerprint/agent NPM package.
Call the start() function to initialize the JavaScript agent for your Fingerprint workspace.
If you are just getting started with Fingerprint, we recommend reading the following guides first:
start() options
To configure the agent, pass parameters into the start() function.
apiKey
Required: yes for NPM installation Type: string
Your public API key to authenticate the agent. You can get one at dashboard.fingerprint.com. If you log into this documentation portal through the dashboard, you will be able to see your personal API key in the example below.
Example usage:
region
Required: no Default:Use this parameter to specify the region you picked for your workspace during registration (defaults to"us"Type:stringAvailable values:"us","eu"and"ap"
us).
The Fingerprint Platform CDN can usually determine the region automatically using your API Key. Nevertheless, we recommend you specify it explicitly. Our proxy integrations rely on the region parameter, as they do not have access to the same internal API that our CDN does. Even if you use our CDN, specifying the region explicitly will keep your JS agent working correctly if our internal API is temporarily disrupted.
Example:
endpoints
Required: no Default: (depends on the region) Type: string | string[]
This parameter should only be used with the Custom subdomain or a cloud proxy integration. Specify your custom endpoint URL here.
Multiple endpoints can be set using an array. The JS agent will try to send the request with the first endpoint, and if the request fails, retry the request with the second endpoint, and so on. Use Fingerprint.withoutDefault() helper if you want to disable our standard fallback endpoints.
storageKeyPrefix
Required: no Default:Name of the key to store visitor data in browsers. The data is stored in cookies and local storage. You shouldn’t change this parameter once your code runs in production. The change will cause the data in visitor browsers to be purged which will decrease the identification accuracy.'_vid_'Type:string
urlHashing
Only for NPM installation Required: no Default:undefined(no hashing) Type:UrlHashingSince: v3.11.0
urlHashing flags ensure no PII or secret data get unintentionally leaked through path, query or fragment values in an URL by replacing raw values with a securely encoded hash.
urlHashing configuration has no effect on performance or accuracy of Identification and Smart Signals products.UrlHashing type has the following configuration structure
pathreplaces the path portion of the URL with a securely encoded hash if set totruequeryreplaces the query portion of the URL with a securely encoded hash if set totruefragmentreplaces the fragment portion of the URL with a securely encoded hash if set totrue
path, query or fragment is replaced with a single value that represents a securely encoded hash of the original URL parts.
Example:
The following example illustrates the behavior of our JS agent without and with the urlHashing flags configured. Original URL represents the URL we would normally send to our backend (in an obfuscated form) Result shows how our JS agent hashes the URL if the path, query and fragment parameters of urlHashing were set to true respectively. The order of the query parameters has no effect on the output hash.
Original URL
https://example.com/test?param1=somePII¶m2=clientSecret¶m3=tokenValue#id342324
path enabled | query enabled | fragment enabled | Result |
|---|---|---|---|
| NO | YES | NO | https://example.com/test?UNrfPps8c1O_mrVgqvhVju4SCMDncBNJat8_iDK-00M#id342324 |
| YES | NO | NO | https://example.com/n4bQgYhMfWWaL-qgxVrQFaO_TxsrC4Is0V1sFbDwCgg?param1=somePII¶m2=clientSecret¶m3=tokenValue#id342324 |
| NO | NO | YES | https://example.com/test?param1=somePII¶m2=clientSecret¶m3=tokenValue#rws4nbTyh7ALUYP6QsxMBWqGTa2T0QzIWHBSRr0rHDo |
| YES | YES | YES | https://example.com/n4bQgYhMfWWaL-qgxVrQFaO_TxsrC4Is0V1sFbDwCgg?UNrfPps8c1O_mrVgqvhVju4SCMDncBNJat8_iDK-00M#rws4nbTyh7ALUYP6QsxMBWqGTa2T0QzIWHBSRr0rHDo |
If either
query, param or fragment part are empty, they are returned as-is without hashing. As an example URL https://example.com/?# stays as is.cache
Only for NPM installation Required: no Default:Added in version 4, the JavaScript agent now contains predefined caching options. By default, the agent does not cache any information and every call toundefined(do not use cache) Type:CacheConfigSince: v4.0.0
get() results in a full billable event (sending signals to our backend and receiving a result). This is because caching can be detrimental to the accuracy and efficacy of our products (both Identification, and more prominently Smart Signals).
CacheConfig
The full CacheConfig type definition is
storage determines where the JavaScript agent stores the cached information, by default it stores the information in memory (agent option).
Each storage option has the following semantics
sessionStoragemeans the cached information is stored in the Session Storage and clears when the browser/tab gets closed. Session storage outlives page refreshes as long as the same tab and origin remain open.localStoragemeans that the cached information is stored in the Local Storage and outlives browser restarts (and never expires by default).agentmeans that the cached information is stored in memory and clears with page (and agent) reloads.
duration represents the amount of time needed to clear the cache, it supports two predefined values and an arbitrary number option (with an upper limit).
optimize-coststores information in cache for 1 houraggressivestores information in cache for 12 hours (we don’t recommend usingaggressivein fraud protection use cases)- when supplied with a
number, the agent stores the cache information for the exactnumberof seconds. Maximum value is43200and the agent will throw an error when a higher value was used.
cachePrefix is a prefix of the string key used to store the cached information (applies to sessionStorage and localStorage storage options).
start() response
The start() function synchronously returns the JavaScript agent instance. The instance has a get() method you can use to identify visitors. Always call the start() method as soon as possible on the page as it influences how long does the get() method take to finish and return results.