Conversions
Tie orders to the visits that made them, so revenue shows up per agent.
Call trackConversion on your server where an order is confirmed. The customer's email (or account id) is hashed with SHA-256 on your server before it is sent, so the raw value never reaches us.
Workers
import { trackConversion } from "./agent-analytics"
await trackConversion(req, ctx, { siteId: env.AA_SITE_ID, secret: env.AA_SECRET }, {
ref: order.id,
value: order.total,
customer: order.email,
items: order.items.map((i) => ({ id: i.sku, qty: i.qty })),
})Next.js and Node
Pass the visit id from the aa_sid cookie:
import { cookies } from "next/headers"
import { trackConversion } from "@/lib/agent-analytics"
await trackConversion({ siteId: process.env.AA_SITE_ID!, secret: process.env.AA_SECRET! }, {
sid: (await cookies()).get("aa_sid")?.value ?? "",
ref: order.id,
value: order.total,
customer: order.email,
})In Node, visitId(req) from the kit returns the same value.
What it unlocks
- Revenue from automated visitors next to people on the overview.
- "Bought" as the last step of every agent funnel.
- Linking: several different customers buying from one device is a strong sign of an agent working for many people.