Server events
NestJS
Send server-side conversions from NestJS — forwarded from the request, credited to the real visitor.
Fire a server-side conversion from a NestJS controller, crediting the real browser visitor:
import { Controller, Post, Req } from '@nestjs/common';import { Request } from 'express';@Controller('checkout')export class CheckoutController { @Post('success') async success(@Req() req: Request) { const forwarded = (req.headers['x-forwarded-for'] as string | undefined) ?? ''; const ip = forwarded.split(',')[0].trim() || req.ip; 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: req.path, ip, user_agent: req.headers['user-agent'], }), }); return { ok: true }; }}Note
NestJS on Express exposes req.path and req.ip; trust the proxy (app.set('trust proxy', true)) so req.ip is the real client when X-Forwarded-For is absent.
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.