Skip to main content

Get Started with Fingerprint

To get started with Fingerprint, you need to install the Fingerprint client on your website.

Install Fingerprint Client

To install, add any of the following scripts to your webpage. These scripts all load the Fingerprint agent, but are activated at different stages when accessing a webpage.

info

For each example, replace the DS_URL placeholder with the data service URL given to you by Macrometa

This script loads the Fingerprint agent at page load time to run the function that generates the visitorId. The visitorId is returned in the response header (x-photoniq-vid) and the JSON body’s response (visitorId).

<body>
<!-- Content of your body here... -->

<!-- Get the script in your application -->
<script src="https://<HOST-TO-DS-SERVICE>/api/ds/v1"></script>
<script>
async function recordVisit() {
try {
// Initialize the agent at application startup.
const dsClient = await DS_Client.load();

// Get the visitor details
const dsData = await dsClient.get();

// Record a visit in the server
const response = await fetch("https://<HOST-TO-DS-SERVICE>/api/ds/v1/visits", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "apikey <DS-APIKEY>"
},
body: JSON.stringify(dsData)
});

if (!response.ok) {
throw new Error('Network response was not ok');
}

const responseBody = await response.json();
console.log(responseBody);
} catch (error) {
console.error(error);
}
}

recordVisit();
</script>
</body>
note

After incorporating the Fingerprint client, it is advisable to integrate Fingerprint as a first-party for improved accuracy as the default third-party integration reduces accuracy and functionality on some browsers.

Fingerprint Response Headers

Fingerprint returns the following headers in the response:

  • x-photoniq-dsid - The device signature
  • x-photoniq-vid - The visitor ID