Server events
Spring Boot
Send server-side conversions from Spring Boot — forwarded from the request, credited to the real visitor.
Fire a server-side conversion from a Spring Boot @RestController, forwarding the visitor's request:
import jakarta.servlet.http.HttpServletRequest;import java.net.URI;import java.net.http.HttpClient;import java.net.http.HttpRequest;import java.net.http.HttpResponse.BodyHandlers;import org.springframework.web.bind.annotation.PostMapping;import org.springframework.web.bind.annotation.RestController;@RestControllerpublic class ConversionController { @PostMapping("/checkout/success") public String recordConversion(HttpServletRequest request) throws Exception { String xff = request.getHeader("X-Forwarded-For"); String ip = (xff != null && !xff.isBlank()) ? xff.split(",")[0].trim() : request.getRemoteAddr(); String userAgent = request.getHeader("User-Agent"); String body = "{" + "\"event_name\":\"success\"," + "\"name\":\"signup\"," + "\"page_path\":\"" + request.getRequestURI() + "\"," + "\"ip\":\"" + ip + "\"," + "\"user_agent\":\"" + userAgent + "\"" + "}"; HttpClient.newHttpClient().send( HttpRequest.newBuilder(URI.create("https://datalook.app/event")) .header("Authorization", "Bearer YOUR_API_KEY") .header("Content-Type", "application/json") .POST(HttpRequest.BodyPublishers.ofString(body)) .build(), BodyHandlers.discarding()); return "ok"; }}Note
request.getRequestURI() returns the real request path (e.g. "/checkout/success"); use it rather than getRequestURL(), which includes the scheme and host.
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.