Documentation
Analytics & Event Tracking
LeadMachine uses Google Analytics 4 (GA4) to track key user actions and business metrics. This helps you understand user behavior, measure feature adoption, and track business growth.
Technical Documentation - SuperAdmin Access Only
Overview
GA4 tracking is implemented across the application to capture:
- Revenue events - Subscriptions, payments, cancellations
- Feature usage - AI enrichment, lead creation, imports
- Growth metrics - Team invites, company signups, Shopify connections
GA4 Configuration
| Setting | Value | ||
| --------- | ------- | ||
| Measurement ID | G-6B3D6J11MZ | ||
| API Secret | Set via GA4_API_SECRET environment variable | ||
| Event | Description | Location | Key Parameters |
| ------- | ------------- | ---------- | ---------------- |
purchase | Subscription completed | billing-success.php | transaction_id, value, currency, items |
checkout_start | Started checkout flow | create-checkout-session.php | company_id, user_count |
payment_successful | Invoice paid (webhook) | stripe-webhook.php | company_id, amount, subscription_id |
subscription_canceled | Subscription canceled | stripe-webhook.php | company_id, subscription_id |
company_created | New company signup | create-company.php | company_id |
| Event | Description | Location | Key Parameters |
| ------- | ------------- | ---------- | ---------------- |
ai_enrich_lead | Lead AI enrichment completed | enrich-lead.php | company_id, entity_id, fields_found |
ai_enrich_company | Company AI enrichment completed | enrich-company.php | company_id, entity_id, fields_found |
team_member_invited | Team member added | invite-user.php | company_id, role, is_new_user |
lead_created | Lead manually created | create-lead.php | company_id, source |
leads_imported_csv | CSV import completed | import-csv.php | company_id, imported_count, skipped_count |
shopify_connected | Shopify store connected | shopify-oauth-callback.php | company_id, shop_domain |
| Event | Description | Location | Key Parameters |
| ------- | ------------- | ---------- | ---------------- |
task_created | Task created | tasks/create.php | company_id, related_entity_type |
coupon_applied | Coupon code applied | apply-coupon.php | company_id, coupon_code |
| File | Purpose | ||
| ------ | --------- | ||
includes/ga4-tracking.php | PHP helper functions for server-side tracking | ||
assets/js/ga4-tracking.js | JavaScript helper for client-side tracking | ||
includes/header.php | Loads gtag.js and ga4-tracking.js |
Last Updated: December 2025