Skip to main content

Using Fingerprint in Google Chrome Extensions

A typical use-case represents getting a valid visitorId among other result data via your extension. After validating it with the Server API or webhooks, data provided by Fingerprint might be crucial for your internal decision making, user scoring, and protecting sensitive actions for your business. There are two general strategies to integrate Fingerprint into an extension. You can get Fingerprint result by opening your website temporarily in a new window. Another way demonstrates injecting the FingerprintJS JavaScript agent into the website’s iframe and performing fingerprinting there. Both solutions are showcased in the Chrome extension repository. The example extension is also available on the Chrome Web Store.

New window strategy

With this approach, the Chrome extension creates a new window that points to an external website hosted by you. This website uses our Fingerprint agent to obtain the result. This data is then passed back to the extension using a native communication channel.

Sample use

  1. Configure and serve a publicly available web page containing the Fingerprint JavaScript agent. It’s recommended to use the Custom subdomain setup or one of our cloud proxy integration to protect the JavaScript agent from ad blockers and increase accuracy. This website must be served over HTTPS.
JavaScript
  1. In the extension’s manifest.json, add the externally_connectable manifest property. Make sure you’ve specified the service_worker property in the background section as well.
JavaScript
  1. Add the following code snippet into your background script. It will allow you to obtain results from Fingerprint inside your extension’s codebase.
JavaScript
  1. Receive and use the result data in your extension’s logic.
JavaScript

Iframe strategy

With this strategy, the extension appends an iframe into the DOM with the URL of the external website and communicates with it using Window.postMessage() API. Alternatively, you can append the iframe into the DOM served on the extension page (e.g. in the popup). There are several benefits of not using a content script:
  • Other extensions don’t have access to the iframe content (e.g. adblockers).
  • There are no required special permissions in the manifest.json.
  • Several anti-fingerprinting techniques and tracking protections can’t identify and block this approach.

Sample use

  1. Configure and serve a publicly available web page containing the Fingerprint JavaScript agent. It’s recommended to use the Custom subdomain. The website must be served over HTTPS.
  1. Add the following code to your extension where you need to get result data.
DOM API and background scriptsWith this approach, your extension needs access to the DOM API, therefore, according to the Manifest v3 limitations, it’s not possible to use the following snippet in the background script.
JavaScript

Documentation

You can find the full documentation in the official GitHub repository.