Full Answer
When an AI agent completes a WooCommerce purchase through MCP or a headless API call, there's no browser session, no cookies, and no JavaScript execution. Client-side tracking pixels — GTM tags, Facebook Pixel, GA4's gtag — never fire because there's no DOM to fire them in. The purchase is real, but from the perspective of every client-side analytics tool, it didn't happen.
Server-side tracking solves this by hooking into WooCommerce's PHP order lifecycle. At the woocommerce_checkout_order_processed and woocommerce_payment_complete hooks, you have access to the full HTTP request context. An agent purchase arrives with identifiable headers — an MCP session token, an API key, or a missing User-Agent — that a human browser session wouldn't have. Tagging the order at this point with a cohort flag (agent vs human) means every downstream event carries that label.
The separation matters for measurement integrity. If agent purchases route into the same GA4 property and ad platform conversion streams as human purchases, bidding algorithms train on a blended signal. Campaigns optimise toward conversions they didn't influence, inflating reported ROAS and distorting budget allocation. Routing agent conversions to a dedicated stream keeps the human attribution chain clean. A detailed walkthrough of the architecture covers the hook placement, header inspection patterns, and downstream routing logic.