Server events
Phoenix
Send server-side conversions from Phoenix (Elixir) — forwarded from the request, credited to the real visitor.
Send a conversion from a Phoenix controller action, crediting the real visitor:
defmodule MyAppWeb.CheckoutController do use MyAppWeb, :controller def success(conn, _params) do ip = case Plug.Conn.get_req_header(conn, "x-forwarded-for") do [forwarded | _] -> case String.split(forwarded, ",") do [first | _] when first != "" -> String.trim(first) _ -> conn.remote_ip |> :inet.ntoa() |> to_string() end [] -> conn.remote_ip |> :inet.ntoa() |> to_string() end user_agent = case Plug.Conn.get_req_header(conn, "user-agent") do [ua | _] -> ua [] -> "" end Req.post("https://datalook.app/event", headers: [{"authorization", "Bearer YOUR_API_KEY"}], json: %{ "event_name" => "success", "name" => "signup", "page_path" => conn.request_path, "ip" => ip, "user_agent" => user_agent } ) json(conn, %{ok: true}) endendNote
conn.request_path already includes the leading slash; get_req_header/2 always returns a list, so match on the head rather than treating it as a string.
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.