Why Webhook-driven Purchase
Payment-complete webhook events are generally more reliable for purchase truth than frontend page timing after checkout redirects.
Dummy Send Example
const payload = {
client_id: "1234567890.1234567890",
events: [
{
name: "purchase",
params: {
transaction_id: "ORDER-10001",
value: 12345,
currency: "JPY",
},
},
],
};
await fetch("https://www.google-analytics.com/mp/collect?measurement_id=G-XXXXXXX&api_secret=DUMMY_SECRET", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
});
All values above are placeholders for explanation only.
Operational Guardrails
- Deduplicate by
transaction_id - Define fallback when
client_idis missing - Monitor success/failure and prepare retry policy