Cherry Seed

How do you separate agent purchases from human purchases?

agent-separation server-side-tracking php-hook cohort-tagging conversion-routing

Quick Answer

Server-side tracking at the WooCommerce PHP order hook is the only reliable separation point. At woocommerce_checkout_order_processed, you can inspect HTTP headers, check for MCP or API origin, and tag each order with a cohort flag before any downstream pixel fires (Seresa, 2026). Server-side hook-based tracking is unaffected by HPOS migrations, Blocks checkout, and theme changes that break client-side plugins. Human conversions then route to GA4 and ad platform APIs while agent conversions route to a separate measurement stream, preventing bidding algorithms from training on mixed data.

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.

Sources

Programmatic Access

GET https://seresa.io/wp-json/cherry-tree-by-seresa/v1/seeds/1152

Cite This Answer

Cherry Tree by Seresa - https://seresa.io/seed/server-side-tracking/how-to-separate-agent-purchases-human-woocommerce