Add Umami custom event tracking across all key pages
- Created /js/pw-analytics.js with conversion funnel events - Added to Base.astro layout (all Astro pages) + 6 static HTML pages - Events tracked: compliance-check-start, compliance-check-complete, order-cta-click, checkout-page-view, checkout-start, esign-opened, esign-submitted, campaign-click (UTM attribution), contact-form-submit - Server-side payment-complete event from checkout webhook via Umami API - Auto-tracks any element with data-track="event-name" attribute Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
19eb8ff2e8
commit
bd5193e45f
9 changed files with 163 additions and 6 deletions
|
|
@ -1240,6 +1240,32 @@ export async function handlePaymentComplete(
|
|||
}
|
||||
}
|
||||
|
||||
// ── Umami analytics — server-side payment event ─────────────────────────
|
||||
try {
|
||||
const umamiUrl = process.env.UMAMI_URL || "http://umami:3000";
|
||||
const websiteId = "55250014-ee15-44ac-a1f6-81dabad3fe0f";
|
||||
await fetch(`${umamiUrl}/api/send`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json", "User-Agent": "PW-API/1.0" },
|
||||
body: JSON.stringify({
|
||||
payload: {
|
||||
website: websiteId,
|
||||
hostname: "performancewest.net",
|
||||
url: `/checkout/complete/${order_type}`,
|
||||
name: "payment-complete",
|
||||
data: {
|
||||
order_type,
|
||||
order_id,
|
||||
payment_method: paymentMethod,
|
||||
total_cents: Number(order.service_fee_cents || order.total_cents || 0),
|
||||
service: (order.service_slug as string) || order_type,
|
||||
},
|
||||
},
|
||||
type: "event",
|
||||
}),
|
||||
});
|
||||
} catch { /* non-fatal */ }
|
||||
|
||||
// ── Advance ERPNext Sales Order workflow (CRTC) ────────────────────────
|
||||
if (order_type === "canada_crtc") {
|
||||
const soName = (order.erpnext_sales_order as string) || null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue