Overview
This tutorial covers how to use Fingerprint to enforce bans on your platform by recognizing the same device even when a user changes accounts. You’ll begin with a starter app that shows a simple ticket resale marketplace: a page displaying existing listings and a form to post new ones. From there, you’ll add the Fingerprint JavaScript agent to identify each visitor and use server-side logic to detect and block submissions from banned visitors. By the end, you’ll have a sample app that prevents banned users from re-posting listings, even if they change their email address or use a new account. This tutorial uses just plain JavaScript and a Node server with SQLite on the back end. For language- or framework-specific setups, see our quickstarts.Estimated time: < 15 minutes
Prerequisites
Before you begin, make sure you have the following:- A copy of the starter repository (clone with Git or download as a ZIP)
- Node.js (v20 or later) and npm installed
- Your favorite code editor
- Basic knowledge of JavaScript
1. Create a Fingerprint account and get your API keys
- Sign up for a free Fingerprint trial, or log in if you already have an account.
- After signing in, go to the API keys page in the dashboard.
- Save your public API key, which you’ll use to initialize the Fingerprint JavaScript agent.
- Create and securely store a secret API key for your server. Never expose it on the client side. You’ll use this key on the backend to retrieve full visitor information through the Fingerprint Server API.
2. Set up your project
- Clone or download the starter repository and open it in your editor:
Terminal
- This tutorial will be using the
ban-evasionfolder. The project is organized as follows:
Project structure
- Install dependencies:
Terminal
- Copy or rename
.env.exampleto.env, then add your Fingerprint API keys:
Terminal
- Start the server:
Terminal
- Visit http://localhost:3000 to view the mock ticket listing page from the starter app. Create a few listings using the form at the bottom and they’ll appear in the list above. Click Admin mode in the top right to simulate admin access, then use Ban seller on any listing. This blocks that specific email address from posting again. Try creating another listing with the same email and you’ll see it’s rejected but simply changing the email will allow the submission to go through.
3. Add Fingerprint to the front end
In this step, you’ll load the Fingerprint client when the page loads and trigger identification when the user clicks Post listing. The client returns both avisitorId and a requestId. Instead of relying on the visitorId from the browser, you’ll send the requestId to your server along with the listing data. The server will then call the Fingerprint Events API to securely retrieve the full identification details, including bot detection and other Smart Signals.
- At the top of
public/index.js, load the Fingerprint JavaScript agent:
public/index.js
- Make sure to change
regionto match your workspace region (e.g.,eufor Europe,apfor Asia,usfor Global (default)). - Near the bottom of
public/index.js, the Post listing button already has an event handler for submitting the listing details. Inside this handler, request visitor identification from Fingerprint using theget()method and include the returnedrequestIdwhen sending the request to the server:
public/index.js
get() method sends signals collected from the browser to Fingerprint servers, where they are analyzed to identify the visitor. The returned requestId acts as a reference to this specific identification event, which your server can later use to fetch the full visitor details.
For lower latency in production, check out our documentation on using Sealed Client Results to return full identification details as an encrypted payload from the get() method.
4. Receive and use the request ID to get visitor insights
Next, pass therequestId through to your server-side listing logic, initialize the Fingerprint Server API client, and fetch the full visitor identification event so you can access the trusted visitorId and Smart Signals.
- In the back end, the
server/server.jsfile already defines API routes for the app. Notice that thePOST /api/listingsroute simply passes the request body to apostListingfunction that is defined in theserver/listings.jsfile:
server/server.js
- The
server/listings.jsfile contains the logic for handling listing submissions and ban enforcement. Start by importing and initializing the Fingerprint Server API client there, and load your environment variables withdotenv:
server/listings.js
- Make sure to change
regionto match your workspace region (e.g.,EUfor Europe,APfor Asia,Globalfor Global (default)). - Update the
postListingfunction to extractrequestIdand use it to fetch the full identification event details from Fingerprint so you can log thevisitorIdalongside each listing:
server/listings.js
requestId, the Fingerprint server client will retrieve the full data for the visitor identification request. The returned object will contain the visitor ID, IP address, device, and browser details, and Smart Signals like bot detection, browser tampering detection, VPN detection, and more.
You can see a full example of the event structure and test it with your own device in our demo playground.
For additional checks to ensure the validity of the data coming from your front end, view how to protect from client-side tampering and replay attacks in our documentation.
5. Block suspicious devices
This optional step uses Smart Signals, which are only available on paid plans.
- Continuing in the
postListingfunction inserver/listings.js, read the Suspect Score from theeventobject and apply any additional rules you want based on it:
server/listings.js
6. Enforce bans using visitor IDs
Next, use the trustedvisitorId from the event object to enforce your ban rules. If a visitor (visitorId) tries to create a new listing after being banned, reject the submission. In production, you may choose to apply different actions for banned visitors, such as blocking specific actions, requiring additional review, or flagging the account for your trust and safety team.
Note: The starter app includes a SQLite database with some tables already created for you:
SQLite database tables
- First update the existing
saveListinghelper function to store thevisitorIdalongside a new listing:
server/listings.js
- Then update the existing
isSellerBannedhelper function to use thevisitorIdinstead of email to check for banned visitors:
server/listings.js
- Next update
banSellerfunction so it looks up the listing’s associated visitor ID instead of email address:
server/listings.js
- Finally, update
postListingto include thevisitorIdwhen checking if the visitor is banned and when saving new listings:
server/listings.js
visitorId ensures that a banned visitor cannot return simply by changing their email address. You can expand the logic by adding more Smart Signals, adjusting thresholds, or customizing how bans are applied based on your business rules.
This is a minimal example to show how to implement Fingerprint for ban
enforcement. In a real application, make sure to implement proper security
practices, error checking, and access-control flows that align with your
production standards.
7. Test your implementation
Now that everything is wired up, you can test the full ban evasion flow.- Start your server if it isn’t already running and open http://localhost:3000:
Terminal
- Try posting a listing by filling out the form at the bottom of the page and clicking Post listing. You should see a success response and the listing will appear in the list above.
- Click Admin mode in the top right to toggle admin controls, then click Ban seller on one of the listings that you created.
- Try to post another listing. The submission will be blocked because Fingerprint recognizes the banned visitor ID
- Open the page in an incognito window and try posting a new listing. The request is still blocked, since Fingerprint continues to recognize the visitor.