Install the @tracio/client SDK and generate your first visitor fingerprint in 5 minutes
This guide walks you through integrating tracio.ai into your application. You will install the client SDK, identify your first visitor, and verify the result via our API.
Install the tracio.ai client library using your preferred package manager:
npm install @tracio/clientOr with yarn:
yarn add @tracio/clientOr include directly via CDN:
<script src="https://your-domain.com/tracio-client.js"></script>Import and initialize the tracio.ai agent with your API key. The load() call returns a promise that resolves once the agent is ready to collect signals.
import Tracio from '@tracio/client';// Initialize the agentconst tracio = await Tracio.load({ apiKey: 'your-api-key', endpoint: 'https://api.tracio.ai', region: 'eu',});| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | required | Your API key for authentication |
endpoint | string | auto | Custom endpoint URL (for custom domain setups) |
region | string | "us" | Server region: "us", "eu", or "ap" |
Call tracio.get() to collect browser signals and receive a visitor identification result. This is an asynchronous operation that takes approximately 50-150ms.
const result = await tracio.get();console.log(result.visitorId); // "X7fh2Hg9LkMn3pQr"console.log(result.confidence); // 0.995console.log(result.requestId); // "1710432000_abc123def"Pass extendedResult: true to receive additional visitor metadata including bot detection, IP intelligence, and smart signals:
const result = await tracio.get({ extendedResult: true });console.log(result.visitorId); // "X7fh2Hg9LkMn3pQr"console.log(result.bot.result); // "notDetected"console.log(result.ipLocation.city.name); // "Prague"console.log(result.incognito); // falseYou can attach metadata to identification requests for later filtering:
const result = await tracio.get({ tag: { userId: 'user_12345', action: 'login', }, linkedId: 'session_abc',});For security-critical operations (login, payment, account creation), always verify the identification result on your server. Never trust client-side data alone.
Query the Server API with the requestId to retrieve the full identification result:
// Server-side (Node.js)const response = await fetch( `https://api.tracio.ai/api/v1/events/${requestId}`, { headers: { 'Authorization': `Bearer ${API_SECRET}`, }, });const event = await response.json();// Verify the visitorconst visitorId = event.products.identification.data.visitorId;const confidence = event.products.identification.data.confidence.score;const isBot = event.products.botd.data.bot.result !== 'notDetected';if (isBot) { return res.status(403).json({ error: 'Bot detected' });}if (confidence < 0.9) { return res.status(401).json({ error: 'Low confidence, please verify' });}Configure a webhook to receive identification events in real-time:
// Express.js webhook handlerapp.post('/webhook/tracio', async (req, res) => { const event = req.body; const visitorId = event.visitorId; const requestId = event.requestId; const bot = event.bot; console.log(`Visitor ${visitorId} identified (request: ${requestId})`); await db.visits.insert({ visitorId, requestId, timestamp: new Date(), isBot: bot.result !== 'notDetected', confidence: event.confidence.score, }); res.status(200).send('OK');});Open your browser's developer console and verify the integration is working:
const tracio = await Tracio.load({ apiKey: 'your-api-key' });const result = await tracio.get({ extendedResult: true });console.log(JSON.stringify(result, null, 2));You should see a response containing:
visitorId — a 16-20 character alphanumeric identifierconfidence — a score between 0.0 and 1.0 (typically above 0.99)requestId — a unique identifier for this eventbot — bot detection resultipLocation — geolocation data derived from the visitor's IPasync function handleLogin(email: string, password: string) { const tracio = await Tracio.load({ apiKey: 'your-api-key' }); const { visitorId, requestId } = await tracio.get(); const response = await fetch('/api/login', { method: 'POST', body: JSON.stringify({ email, password, visitorId, requestId }), }); return response.json();}async function processPayment(paymentData: PaymentData) { const tracio = await Tracio.load({ apiKey: 'your-api-key' }); const result = await tracio.get({ tag: { action: 'payment', amount: paymentData.amount }, linkedId: paymentData.orderId, }); const response = await fetch('/api/payment', { method: 'POST', body: JSON.stringify({ ...paymentData, visitorId: result.visitorId, requestId: result.requestId, }), }); return response.json();}Use the official Go SDK to verify identification results on your server:
go get github.com/tracio-ai/tracio-gopackage mainimport ( "fmt" "log" tracio "github.com/tracio-ai/tracio-go")func main() { client := tracio.NewClient("your-secret-key") event, err := client.GetEvent(requestID) if err != nil { log.Fatal(err) } fmt.Printf("Visitor: %s, Confidence: %.3f\n", event.VisitorID, event.Confidence)}Use the Rust SDK for high-performance server-side verification:
[dependencies]tracio = "0.1"tokio = { version = "1", features = ["full"] }use tracio::Client;#[tokio::main]async fn main() { let client = Client::new("your-secret-key"); let event = client.get_event(request_id).await.unwrap(); println!("Visitor: {}, Confidence: {:.3}", event.visitor_id, event.confidence);}Test the Server API directly from your terminal:
curl https://api.tracio.ai/v1/events/YOUR_REQUEST_ID \ -H "Auth-API-Key: your-secret-key"Ensure your Go version is 1.21 or later. Run go version to check. For Rust, ensure you have Rust 1.70+ with rustc --version.
If you see TLS handshake failures, configure a proxy endpoint using your own domain. See Cloudflare or AWS CloudFront integration guides for first-party proxy setup.
Enable async collection mode by setting extendedResult: true in your tracio.get() call. This enables all 1,200+ signal collectors including canvas, WebGL, and audio probes that require asynchronous rendering.
See the self-hosting documentation for Docker Compose templates, environment variable reference, and production configuration guides.