Server events
SvelteKit
Send server-side conversions from a SvelteKit route handler — forwarded from the request, credited to the real visitor.
Fire a server conversion from a SvelteKit +server.ts route handler:
import { json } from '@sveltejs/kit';import type { RequestHandler } from './$types';export const POST: RequestHandler = async ({ request, getClientAddress, url }) => { const xff = request.headers.get('x-forwarded-for'); const ip = xff ? xff.split(',')[0].trim() : getClientAddress(); await fetch('https://datalook.app/event', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ event_name: 'success', name: 'signup', page_path: url.pathname, ip: ip, user_agent: request.headers.get('user-agent') ?? '' }) }); return json({ ok: true });};Note
In a form action use event.request.headers, event.getClientAddress(), and event.url.pathname — the same accessors, just off the action's event object.
How it’s credited
This reads the visitor’s IP and User-Agent from the request and forwards them, so the conversion lands on the real visitor — device, country, and source included. No
identify(), no ids, no cookie. Get an API key in the dashboard under Track it from your server; see the overview for the concepts and the webhook path.