Build an AI agent to flag LTV cohorts missing CAC payback
Most DTC brands find out a cohort went underwater three quarters too late. By the time someone pulls the blended LTV:CAC number and notices it's slipping, you've already spent another two months of ad budget acquiring more customers who look just like the ones that never paid back. An AI agent that watches cohort-level payback in near real time isn't a nice-to-have dashboard feature — it's the difference between catching a bad channel in week six versus finding it in the Q3 board deck.
Why blended metrics hide the rot
Blended CAC and blended LTV smooth over exactly the thing you need to see. A brand can have a Meta prospecting cohort from March that's paying back in 4 months next to a TikTok cohort from May that never breaks even, and the company-wide average still looks fine because organic and email cohorts are propping it up.
Cohort drift is a leading indicator, not a lagging one. It shows up first in early repeat purchase rate, then in 90-day contribution margin, then in 6-month LTV — long before it hits the P&L as a CAC payback problem everyone can see. An agent's job is to catch it at the leading edge, not wait for the lagging confirmation.
The reason teams miss this manually isn't lack of data — most have the orders table, the ad spend table, and a warehouse. It's that nobody has time to re-run cohort payback math by channel, by acquisition month, by product category, every week. That's exactly the kind of repetitive, rules-based comparison an agent should own.
What the agent actually needs to track
Before writing a line of code, define what "drifting below payback" means numerically. Vague thresholds produce noisy agents nobody trusts. You need:
- Cohort definition — group customers by first-order month and acquisition channel, not just calendar month. Channel-level cohorts are where the real signal lives.
- CAC input — fully-loaded CAC per channel per cohort month, including agency fees and platform fees, not just ad spend divided by orders.
- Payback window — pick a business-appropriate window (3, 6, or 12 months) based on your cash cycle, and calculate cumulative contribution margin per cohort at each interval within that window.
- Contribution margin, not revenue — LTV built on revenue alone overstates payback. Strip out COGS, shipping, payment processing, and returns before comparing to CAC.
- Drift threshold — define "flagged" as cumulative contribution margin tracking below a set percentage of CAC at the checkpoint (e.g., below 80% of CAC at month 3 for a 6-month payback target), not just "below CAC" at the end, since you want early warning.
Get these definitions agreed with finance before the agent ships. An agent that fires alerts using a definition finance doesn't trust gets ignored after the second false positive.
The data pipeline the agent sits on
The agent is only as good as the joins underneath it. This part is unglamorous but it's where most of these projects actually fail.
- Order-level data from Shopify or your OMS, with first-order timestamp and customer ID intact through returns and refunds.
- Ad platform spend data from Meta, Google, TikTok, and any affiliate or influencer spend, pulled at the campaign level and mapped to acquisition channel — not just "paid social" as one bucket.
- Attribution mapping that ties each new customer to an acquisition channel using whatever model you trust — last-touch, MTA, or an incrementality-adjusted view. Be honest about the model's limits; the agent inherits its blind spots.
- Cost data from your payment processor and fulfillment provider so contribution margin is real, not revenue dressed up as profit.
All of this needs to land in a warehouse — BigQuery, Snowflake, whatever you run — and get modeled through something like dbt into a clean cohort table: acquisition month, channel, cumulative contribution margin at 30/60/90/180 days, and fully-loaded CAC. This table is the agent's entire world. If it's wrong, the agent is confidently wrong, which is worse than no agent at all.
Building the flagging logic
You don't need a large model to do the math — the math is arithmetic. Where the "AI agent" part earns its keep is in monitoring, comparison, and communication:
- Scheduled comparison — a job that runs weekly, pulls the latest cohort table, and compares each active cohort's trajectory against the payback threshold at its current age.
- Trend detection — flag not just cohorts already below threshold, but cohorts whose trajectory is worse than the prior three cohorts on the same channel at the same age. This catches deterioration before it crosses the line.
- Root cause narrowing — when a cohort flags, have the agent pull the supporting detail automatically: was AOV down, was return rate up, did repeat purchase rate drop, did CAC spike for that channel that month? This is where an LLM layer is genuinely useful — turning a table of deltas into a plain-language summary instead of making a human reverse-engineer it.
- Alerting with context — push flagged cohorts to Slack or email with the specific numbers, the likely driver, and the channel/month at fault. "TikTok cohort, April, tracking at 62% of CAC payback at day 90 versus 95% average for prior three months, driven by a 15% drop in 60-day repeat rate" is actionable. "LTV:CAC declining" is not.
Keep the LLM component scoped to narrative generation and pattern summarization. Let deterministic code own the actual threshold math — you don't want a model hallucinating whether a cohort passed or failed payback.
Closing the loop on alerts
An agent that flags problems and stops is half a solution. Build the action path in from the start:
- Route by owner — channel-specific flags go to the media buyer or agency responsible for that channel, not a generic marketing inbox.
- Set a response SLA — a flagged cohort needs a documented response (pause spend, adjust targeting, accept the loss for strategic reasons) within a set number of days, logged back into the same system.
- Track false positive rate — review flagged cohorts monthly and refine thresholds if the agent is crying wolf. An ignored alert system is worse than none because it trains people to ignore the next real one too.
- Feed decisions back — when a channel gets paused or budget gets reallocated because of a flag, log that action against the cohort record. Over time this becomes a track record proving the agent's ROI, which is what gets you budget to expand it.
The point of this agent isn't a fancier dashboard. It's compressing the time between "a cohort goes bad" and "someone with budget authority knows and acts." Get the cohort definitions right, get the underlying data pipeline clean, and let the agent handle the tedious comparison work every week so your team spends its time on the decisions, not the arithmetic.