Find customers who have gone quiet, with one PostHog query
Copy-and-paste PostHog SQL queries that list the people, companies or accounts whose product usage has halved in the last two weeks, with what the results can and cannot tell you.
Customers nearly always use a product less before they cancel it. If you track usage in PostHog, the warning is already in your data. This page gives you SQL queries you can paste into PostHog to list everyone whose activity has dropped by half or more in the last two weeks, compared with the two weeks before.
It takes about five minutes, needs no extra tools, and does not involve connecting anything to Oskar.
Before you start#
The queries work on any PostHog project, because they count every event and do not rely on events you have named yourself. Pageviews and autocapture are enough to get a result.
They do need people to be identified. An anonymous visitor cannot be tied to a customer, so the queries only count events from people who have an email property, or events that carry a group.
Run this first to see how much of your data is usable. Open the SQL editor in PostHog, paste it in and run it:
SELECT
round(100 * countIf(notEmpty(person.properties.email)) / count()) AS pct_events_identified,
uniqIf(person_id, notEmpty(person.properties.email)) AS identified_people,
countIf(notEmpty($group_0)) AS events_with_a_group
FROM events
WHERE timestamp >= now() - INTERVAL 28 DAY
- identified_people should be roughly the number of people who use your product. If it is far lower, your product is not calling
identifywith an email, and that is the first thing to fix. - pct_events_identified is often low, because visitors to your marketing site are anonymous. That is fine.
- events_with_a_group is above zero only if you use PostHog's group analytics. If it is, use query 3.
Query 1: people whose usage has halved#
Start here if your customers are individuals, or if you are not sure how your tracking is set up.
SELECT
person.properties.email AS email,
countIf(timestamp >= now() - INTERVAL 14 DAY) AS last_14_days,
countIf(timestamp < now() - INTERVAL 14 DAY) AS previous_14_days,
round(100 * (last_14_days - previous_14_days) / previous_14_days) AS change_pct,
uniqIf(toDate(timestamp), timestamp >= now() - INTERVAL 14 DAY) AS active_days_last_14,
max(timestamp) AS last_seen
FROM events
WHERE timestamp >= now() - INTERVAL 28 DAY
AND notEmpty(person.properties.email)
AND person.properties.email NOT ILIKE '%@yourcompany.com'
GROUP BY email
HAVING previous_14_days >= 20
AND last_14_days <= previous_14_days / 2
ORDER BY previous_14_days DESC
LIMIT 100
Change yourcompany.com to your own domain so your team is left out.
Each row is a person who was active in the earlier fortnight and has done half as much, or less, since. change_pct of -100 means they have stopped completely. The list is sorted by how active they used to be, so the people who were getting the most from your product are at the top.
Query 2: companies, by email domain#
If your customers are teams whose staff sign in with work addresses, group by the part of the email after the @.
SELECT
splitByChar('@', lower(person.properties.email))[2] AS domain,
countIf(timestamp >= now() - INTERVAL 14 DAY) AS last_14_days,
countIf(timestamp < now() - INTERVAL 14 DAY) AS previous_14_days,
round(100 * (last_14_days - previous_14_days) / previous_14_days) AS change_pct,
uniqIf(person_id, timestamp >= now() - INTERVAL 14 DAY) AS people_last_14,
uniqIf(person_id, timestamp < now() - INTERVAL 14 DAY) AS people_previous_14,
max(timestamp) AS last_seen
FROM events
WHERE timestamp >= now() - INTERVAL 28 DAY
AND notEmpty(person.properties.email)
GROUP BY domain
HAVING domain NOT IN ('gmail.com', 'googlemail.com', 'outlook.com', 'hotmail.com', 'yahoo.com', 'icloud.com', 'proton.me', 'protonmail.com', 'yourcompany.com')
AND previous_14_days >= 20
AND last_14_days <= previous_14_days / 2
ORDER BY previous_14_days DESC
LIMIT 100
This adds two useful columns: how many people at the company were active in each fortnight. A company that went from five active people to one is in more trouble than its event count alone suggests.
Shared mail providers are left out because a Gmail address does not identify a company. Customers who sign up with personal addresses will be missing from this list; use query 1 or 3 for them.
Query 3: accounts, by PostHog group#
If you use group analytics, this is the most accurate version, because each event already says which account it belongs to.
SELECT
$group_0 AS account,
countIf(timestamp >= now() - INTERVAL 14 DAY) AS last_14_days,
countIf(timestamp < now() - INTERVAL 14 DAY) AS previous_14_days,
round(100 * (last_14_days - previous_14_days) / previous_14_days) AS change_pct,
uniqIf(person_id, timestamp >= now() - INTERVAL 14 DAY) AS people_last_14,
uniqIf(person_id, timestamp < now() - INTERVAL 14 DAY) AS people_previous_14,
max(timestamp) AS last_seen
FROM events
WHERE timestamp >= now() - INTERVAL 28 DAY
AND notEmpty($group_0)
GROUP BY account
HAVING previous_14_days >= 20
AND last_14_days <= previous_14_days / 2
ORDER BY previous_14_days DESC
LIMIT 100
$group_0 is your first group type. If your company or account group is the second type, use $group_1, and so on. The account column shows the group key, which is whatever id your product sends.
Make it sharper: count only the events that matter#
Counting every event treats a pageview the same as real work. If your product sends events for what customers get done, count only those. First see what you have:
SELECT
event,
count() AS events,
uniq(person_id) AS people
FROM events
WHERE timestamp >= now() - INTERVAL 28 DAY
AND notEmpty(person.properties.email)
GROUP BY event
ORDER BY events DESC
LIMIT 30
Pick the two to five events that mean a customer got value, such as report_created or invoice_sent, and add one line to the WHERE clause of any query above:
AND event IN ('report_created', 'invoice_sent')
Now the list shows customers who have stopped doing the thing they pay you for, even if they still log in.
Adjusting the thresholds#
previous_14_days >= 20ignores people who were barely active to begin with. Raise it if the list is full of occasional users; lower it for a product people use rarely.last_14_days <= previous_14_days / 2is the "down by half" rule. Use/ 3for only the steepest drops, or* 0.7to catch a 30% fall.- The 14-day windows suit a product used weekly or more. For a monthly product, change both
14values to30and the28to60.
What the results cannot tell you#
Be careful about reading too much into the list. A generic query has real limits:
- It does not know who pays. PostHog has no idea which of these people are paying customers, on a trial or on a free plan, or what each is worth. You have to check each name against your billing.
- It does not know what normal is. A fortnight's holiday, a seasonal business and a month-end reporting tool all look like a drop.
- Total events are noisy. A background event that fires on a timer can make an idle account look busy, and removing one can make everyone look as if they left.
- Matching is approximate. People who use a different email from the one they pay with, or a personal address at a company, end up in the wrong place or nowhere.
- Nobody runs it. A query is only useful on the day someone remembers to open it.
Depending on your project's settings, person.properties.email is either the email at the time of each event or the person's current one. If someone was identified part-way through the four weeks, their earlier events may not be counted.
What to do with the list#
Take the top five that you recognise as paying customers and get in touch this week. Keep it short and personal: say you noticed they have been using the product less and ask whether something is not working. See churn risk for what to say in each situation, and how to reduce churn in SaaS for what to fix once you see the pattern.
Doing this every night, with billing attached#
Oskar starts from the same idea as these queries and deals with the limits above. It reads your PostHog usage every night and your Stripe billing as it changes, matches usage to the customers who pay, and judges a quiet spell against how often healthy customers use your product. It also tracks the events you say show real value, and adds failing payments, pending cancellations and signs of expansion.
You get a short list of the customers who need you, each with a reason and a suggested next step. Oskar is read-only and never contacts your customers. If your tracking needs work first, sending the right events to PostHog covers what to set up.