Most attribution tools show you conversion events. TrackLayer shows you what happens after — which customers stay active, which channels retain them, and why some channels deliver better ROI than they look on day one.
CREATE MATERIALIZED VIEW v_cohort_retention AS
SELECT
cohort_month,
acquisition_channel,
m0_retention_rate,
m1_retention_rate,
m2_retention_rate,
m3_retention_rate,
m4_retention_rate,
m5_retention_rate,
cohort_size
FROM (
SELECT
DATE_TRUNC(event_time, 'MONTH') AS cohort_month,
acquisition_channel,
-- M+0: same-month retention (purchases within 30 days)
COUNT(DISTINCT customer_id) FILTER (
WHERE event_name = 'purchase' AND
event_time BETWEEN cohort_month AND cohort_month + INTERVAL '30 days'
) OVER (PARTITION BY cohort_month, acquisition_channel)::FLOAT / NULLIF(COUNT(DISTINCT customer_id)
FILTER (WHERE event_name = 'purchase') OVER (PARTITION BY cohort_month, acquisition_channel), 0),
-- M+1 through M+5: retention for months 1-5
... [calculated per month_offset]
FROM events
GROUP BY cohort_month, acquisition_channel
);
-- Refreshed nightly for dashboard performanceFuture months are impossible to observe. When you view a March 2026 cohort in April 2026, the retention rate for months 4, 5, and 6 cannot exist yet — no data has been collected.
Many cohort tools treat these as 0% retention, which creates a misleading downward trend. The chart shows a declining line when in reality the data just doesn't exist yet.
Conditional null display.v_cohort_retention marks cells where cohort_age >= future_months as NULL. Dashboard renders "not yet observed" with a subtle visual cue.
Auto-refresh. Materialized view refreshes nightly. As time passes, NULL cells become actual retention rates automatically — no manual refresh needed.
Insight: Meta shows strongest retention but highest CAC. Klaviyo shows lower first-month retention (email-heavy) but stable engagement. Google has high intent (lower first-month) but steeper decline — may indicate quality issues.
customer_id | rfm_segment | predicted_ltv | m0_retention | m1_retention | m2_retention | acquisition_channel ------------+-------------+--------------+-------------+-------------+-------------+-------------+-------------------- cust_abc | loyal | $842 | 0.81 | 0.76 | 0.74 | Meta cust_def | at_risk | $326 | 0.42 | 0.28 | 0.21 | Google cust_ghi | champion | $2,147 | 0.89 | 0.84 | 0.81 | Klaviyo cust_jkl | lost | $87 | 0.12 | 0.08 | 0.05 | Direct // Insight: Google has high predicted LTV ($326) but poor retention (21% by M2) // Action: Investigate Google post-purchase flow or consider channel optimization
Group by acquisition channel. Meta, Google, TikTok, Klaviyo, Direct.
Visualize cohort × month matrix. Filter by channel, drill into cohorts.
'Not yet observed' cells. No false zero trends.
Combined RFM + retention view (Phase 7.4 + 8.6).
We use essential cookies to keep the site secure and functional. Analytics and third-party tags run only with your consent. See our Cookie Policy.
We use essential cookies to keep the site secure and functional. Analytics and third-party tags run only with your consent. See our Cookie Policy.