Server events
Ruby on Rails
Send server-side conversions from Ruby on Rails — forwarded from the request, credited to the real visitor.
Fire a server-side conversion from a Rails controller action, crediting the real visitor:
require "net/http"require "json"class CheckoutController < ApplicationController def success forwarded = request.headers["X-Forwarded-For"] visitor_ip = forwarded.present? ? forwarded.split(",").first.strip : request.remote_ip uri = URI("https://datalook.app/event") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true req = Net::HTTP::Post.new(uri) req["Authorization"] = "Bearer YOUR_API_KEY" req["Content-Type"] = "application/json" req.body = JSON.generate( event_name: "success", name: "signup", page_path: request.path, ip: visitor_ip, user_agent: request.user_agent ) http.request(req) head :ok endendNote
request.remote_ip already resolves the client through trusted proxies, so it is a safe fallback 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.