Integreer in 3 regels
Kant-en-klare Device Intelligence voor elk framework. Binnen enkele minuten productieklaar.
import { Tracio } from '@tracio/sdk'
const tracio = Tracio.init({ publicKey: '5ca175fc...' })
const { visitorId } = await tracio.getResult()Kies je framework
React
Eigen React-hook voor apparaatidentificatie
import { useVisitorId } from '@tracio/react'
function App() {
const { data: visitorId } = useVisitorId()
return <div>Visitor: {visitorId}</div>
}Next.js
Full-stack Device Identification-integratie voor Next.js (App Router + Pages Router)
// app/layout.tsx
import { TracioProvider } from '@tracio/react'
export default function Layout({ children }) {
return (
<TracioProvider publicKey={process.env.NEXT_PUBLIC_TRACIO_KEY!}>
{children}
</TracioProvider>
)
}Vue
Vue 3-composable voor apparaatidentificatie
<script setup>
import { useVisitorId } from '@tracio/vue'
const { data: visitorId } = useVisitorId()
</script>
<template>
<div>Visitor: {{ visitorId }}</div>
</template>Angular
Injecteerbare Angular-service voor apparaatidentificatie
import { Component, inject, effect } from '@angular/core'
import { TracioService } from '@tracio/angular'
@Component({ ... })
export class AppComponent {
private tracio = inject(TracioService)
constructor() {
// visitorId() is a signal — read it reactively
effect(() => console.log(this.tracio.visitorId()))
}
}Cloudflare
Proxy-integratie via Cloudflare Workers voor first-party routing
// Cloudflare Worker
export default {
async fetch(request, env) {
const url = new URL(request.url)
if (url.pathname.startsWith('/tracio/')) {
return fetch('https://edge.tracio.ai' + url.pathname)
}
return fetch(request)
}
}AWS CloudFront
Proxy-integratie via CloudFront Lambda@Edge origin-request-functie
// Lambda@Edge function
exports.handler = async (event) => {
const request = event.Records[0].cf.request
if (request.uri.startsWith('/tracio/')) {
request.origin = {
custom: {
domainName: 'edge.tracio.ai',
protocol: 'https',
}
}
}
return request
}Google Tag Manager
Laad de Device Identification-agent via een aangepaste HTML-tag in GTM
<!-- GTM Custom HTML Tag -->
<script>
(function() {
var script = document.createElement('script');
// Public key travels in the s.js query string (?k=...)
script.src = 'https://edge.tracio.ai/s.js?k=your-public-key';
script.onload = function() {
window.Tracio.load()
.then(function(tc) { return tc.get(); })
.then(function(result) {
dataLayer.push({
event: 'tracio_loaded',
visitorId: result.visitorId
});
});
};
document.head.appendChild(script);
})();
</script>Go
Ontvang en verifieer identificatie-webhooks in Go (standaardbibliotheek)
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
http.HandleFunc("/webhook/tracio", func(w http.ResponseWriter, r *http.Request) {
body, _ := io.ReadAll(r.Body)
// verify r.Header.Get("X-Tracio-Signature") against body, then act
fmt.Println(string(body))
w.WriteHeader(http.StatusOK)
})
http.ListenAndServe(":8080", nil)
}Rust
Hoogperformante webhookverificatie in Rust met Axum
use axum::{body::Bytes, http::HeaderMap, routing::post, Router};
async fn webhook(headers: HeaderMap, body: Bytes) -> &'static str {
// verify headers["x-tracio-signature"] against body, then act
println!("{}", String::from_utf8_lossy(&body));
"OK"
}
#[tokio::main]
async fn main() {
let app = Router::new().route("/webhook/tracio", post(webhook));
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, app).await.unwrap();
}Node.js
Ontvang en verifieer identificatie-webhooks in Node.js en Express
import express from 'express'
const app = express()
// Capture the raw body so the signature can be verified byte-for-byte.
app.use(express.json({ verify: (req, _res, buf) => ((req as any).rawBody = buf) }))
// Identification events are pushed here in real time
app.post('/webhook/tracio', (req, res) => {
const event = req.body
console.log(event.visitorId, event.bot.result)
res.status(200).send('OK')
})
app.listen(3000)Klaar om te integreren?
Begin met onze Quick Start-gids en voeg in minder dan 5 minuten Device Intelligence toe aan je applicatie.