EatMatrix CAPI Setup - Meta, Stape, GDPR, GTM, GA4 by Nitin UpadhyayEatMatrix CAPI Setup - Meta, Stape, GDPR, GTM, GA4 by Nitin Upadhyay

EatMatrix CAPI Setup - Meta, Stape, GDPR, GTM, GA4

Nitin  Upadhyay

Nitin Upadhyay

Verified

2 collaborators


EatMatrix — Full-Funnel Tracking, Server-Side Attribution & Consent Architecture

Project Overview

EatMatrix is a subscription-based web application with a public marketing website and a logged-in app experience. I was brought in to design, implement, and document a complete tracking and attribution system across:
Marketing website (www.eatmatrix.com)
Logged-in application (app.eatmatrix.com)
Server-side infrastructure (d.eatmatrix.com via Stape)
The goal was not just “tracking events”, but to build a reliable, privacy-aware, deduplicated analytics and ad attribution system that would scale with paid acquisition.

Key Constraints (Very Important)

This project had real-world constraints, not a textbook setup:
No budget for a full CMP (Cookiebot) on the app domain
App is an SPA (Single Page Application)
Consent is handled via custom checkbox + terms acceptance
Client needed GA4 + Meta Ads tracking
Must support:
Client-side tracking
Server-side (CAPI) tracking
Event deduplication
Accurate attribution
Tracking needed to work without breaking conversions due to consent blocking
All architectural decisions were made around these constraints.

What Was Promised (Scope)

Section A — Promised Deliverables

Stape server-side GTM setup
Client-side GTM restructuring
Full funnel event tracking
GA4 + Meta Ads integration
Deduplication logic
Consent-safe implementation (within constraints)
End-to-end documentation for developers and stakeholders

Full Event & Logic Design

Funnel Events Covered

The system tracks every meaningful step in the user journey:
Top / Mid Funnel
Page views
Scroll depth
Outbound link clicks
Lead-related CTA clicks
Signup & Onboarding
signup_complete
Email capture
Registration confirmation
Monetization Flow
view_premium_page
plan_selection
free_trial_toggle
initiate_checkout
purchase_complete
Each event was intentionally chosen to reflect user intent, not vanity interactions.

Client-Side Architecture (www + app)

Section C — Client-Side GTM Setup

1. Google Analytics 4
Central GA4 configuration tag
Event-based tracking using custom events
Funnel-aligned GA4 events:
signup_complete
view_premium_page
initiate_checkout
purchase_complete
2. Meta Pixel (Client Side)
Page View
Lead
Signup Complete
Initiate Checkout
Purchase
View Premium Page
All Meta client-side events were aligned with server-side events using event_id for deduplication.

Button-Level Tracking (No Assumptions)

Every important CTA was tracked using explicit dataLayer pushes, not auto-click guessing.
Examples:
Start free trial
Get started
Join users now
Start scanning now
Try it free
Download scanner
Start using EatMatrix
Each button had:
A unique event name
Snake_case naming
Dedicated GTM triggers
Reusable logic for duplicated buttons
This avoided brittle click selectors and ensured long-term stability.

Data Layer & Parameters

Every key event carried meaningful parameters, not empty events:

Parameters Included

plan_type
currency
value
free_trial_enabled
email (hashed where applicable)
event_id (critical for deduplication)
This ensured:
Clean GA4 reporting
High Meta event match quality
Accurate revenue attribution

Consent Architecture (Critical Part of This Project)

Section B — Consent Logic & Advanced Implementation

Because a full CMP was not available on the app domain, we designed a temporary but robust consent model:
Key Decisions
Consent defaulted to granted on app domain
Consent tied to:
Checkbox for terms & conditions
Explicit user action
No third-party cookies fired before interaction
No consent race conditions in SPA navigation
Why This Was Necessary
In SPAs:
Events often fire before consent updates
Meta & GA4 block events if consent timing is wrong
The solution:
Consent set at Initialization level
No delayed or conflicting consent updates
One single source of truth for consent state
This fixed:
Blocked purchase events
Missing Meta conversions
Inconsistent GA4 data
⚠️ This setup was clearly documented as temporary, with a recommendation to upgrade to a full CMP later for GDPR hardening.

Server-Side Setup (Stape)

Section D — Server-Side GTM

A full Stape-powered server-side GTM container was implemented.
Server Container Purpose
Improve attribution reliability
Bypass browser limitations
Reduce signal loss
Enable Meta Conversions API

Server-Side Tags Implemented

Google Analytics 4 (Server)
Receives events from client GTM
Preserves original parameters
Supports SPA routing
Maintains clean event structure
Meta Conversions API
Server-side Meta events implemented:
Page View
Lead
Signup Complete
View Premium Page
Initiate Checkout
Purchase
Free Trial Toggle
Plan Selection
Each event included:
Event name mapping
Event time
Event ID
User data (hashed email where available)
Custom parameters (plan, currency, value)

Mapping & Deduplication

Client and server events shared the same event_id
Meta automatically deduplicated events
No double-counting
No inflated conversion numbers
This ensured:
Accurate reporting
Stable optimization signals
Clean attribution paths

Debugging & Validation

Section E — Debugging & Quality Assurance

Extensive debugging was performed using:
GTM Preview (client + server)
GA4 DebugView
Meta Events Manager
Consent state inspection
Event timing verification
What Was Verified
Events fire once (not duplicated)
Consent state is granted before events fire
Server-side events receive correct parameters
Meta deduplication works as expected
No blocked events due to consent mismatch

Meta Event Quality & Attribution

Final Meta setup achieved:
Event match quality: 6.2 / 10 (in the first week alone)
Email hashing enabled
Server-side signals active
Stable conversion reporting
Additional attribution improvements (Meta click ID, phone, login ID) were documented as optional future enhancements, not forced.

Documentation Delivered

A very detailed Notion-style documentation was created covering:
What was promised and delivered
Consent architecture decisions
All dataLayer events and parameters
Client-side GTM tags, triggers, variables
Server-side GTM tags and mappings
Debugging steps
Deduplication logic
Future upgrade recommendations (CMP, GDPR hardening)
This documentation allows:
Developers to maintain the setup
Marketers to trust the data
The system to scale without breaking

Final Outcome

✔ Full-funnel tracking implemented ✔ Client + server-side attribution working ✔ Meta & GA4 aligned ✔ Deduplication solved ✔ SPA consent issues resolved ✔ Clear upgrade path documented
This was not a “basic GTM setup” — it was a tracking system engineered under real constraints, optimized for accuracy, stability, and growth.

Like this project

Posted Dec 18, 2025

Designed a complete tracking and attribution system for EatMatrix, enhancing privacy and scalability across multiple domains!