Connecting data

Sending the right events to PostHog

What to track in your product so Oskar can tell a healthy customer from one drifting away - identifying people by email, which events to send, and how to check it worked.

Most of what Oskar can tell you comes from product usage, and product usage comes from the events your product sends to PostHog. Billing says who pays. PostHog says whether they are getting anything for it. The better the events, the sharper Oskar's decisions. This page is for whoever looks after your PostHog setup.

What Oskar needs from PostHog#

Three things, in order of importance:

  1. Every person has an email address. The email is what connects a person in PostHog to the customer who pays.
  2. Events are named for what the customer did. "Created a report", not "clicked button" or "viewed page".
  3. One or two events mean something. The action that shows a new customer is set up, and the few actions that show a customer is getting value.

You do not need event properties, session recordings, feature flags or funnels for Oskar. It reads none of them. See Connecting PostHog for exactly what it reads.

1. Identify people by email#

Oskar's nightly query only returns people whose PostHog person has an email property. Anonymous events are left out, and so is anyone identified by an id alone.

Call identify in your product as soon as you know who someone is, with the email they signed up with, and set the same email from your server on events that matter:

posthog.identify(user.id, { email: user.email })
posthog.capture(
    distinct_id=user.id,
    event='report_created',
    properties={'$set': {'email': user.email}},
)

Two rules make this work well:

  • Use the address they pay with. Oskar matches a person to a customer by their exact email first, then by its domain if you chose that rule. If people sign up with a different address from the one on the invoice, link the two in your own system and send the billing one to PostHog, or set the customer's billing contact to the address they use.
  • Keep one distinct id per person. If your product sometimes identifies someone by email and sometimes by a user id, PostHog may create two people. Pick one id and use it everywhere, and let PostHog merge the anonymous session into it when they sign in.

Customers that are companies#

When one customer is a team, the people in it share a billing customer. Oskar handles this in one of two ways:

  • By company email domain. Everyone with an @acme.com address counts towards the customer billed at @acme.com. This needs no extra setup, but it only works for work addresses. Gmail, Outlook and the like do not identify a company.
  • By PostHog company group. If you use group analytics, set each company group's key to the customer's id in your billing tool (cus_… in Stripe) and Oskar matches on that. It is the most precise option, and the only one that works for teams whose staff use personal addresses.
posthog.group('company', 'cus_NffrFeUfNV2Hib', { name: 'Acme' })

Oskar reads the first group type in your project. You choose the rule in setup and can change it under Settings → Matching.

2. Send events for what the customer did#

Oskar counts how many times each person triggered each event each day. From that it works out whether a customer's usage is rising or falling, how long it has been since anyone used the product, how many people in the customer are active, and whether they still use the features that matter.

That means every event counts as activity, including $pageview and autocapture if you have them on. Those show that someone was there. Events you name yourself show what they got done, and that is what Oskar's best decisions rest on.

Good events#

Name an event for the moment a customer gets something done:

Product Events worth sending
A B2B tool project_created, report_exported, invoice_sent, teammate_invited
A membership or content product report_opened, lesson_completed, webinar_joined, download_saved
An API or developer tool api_key_created, first_request_succeeded, deploy_completed
A marketplace or booking product listing_published, booking_confirmed, payout_received

A few conventions keep them useful over time:

  • Lower case with underscores, in the same shape every time: thing_verb or verb_thing, but not both. Oskar shows them to you as words, so report_created reads as "report created".
  • Stable names. Renaming an event looks to Oskar like every customer stopped doing the old thing. If you must rename, send both names for a month.
  • No ids or variable text in the name. report_created, not report_created_42 or created_quarterly_report. Put detail in properties if you want it for your own analytics. Oskar does not read properties, so they cost nothing.
  • One event per action, not per screen. Three events for one action inflates usage and makes trends noisier.

Events to avoid#

  • Heartbeats, polling and timers. An event sent every 30 seconds while a tab is open makes an idle customer look like your busiest one.
  • Your own staff and test accounts. Keep your team out of the picture by sending their events to a separate PostHog project, or by leaving them unidentified.
  • Pageviews on their own. Keep them if you like, but add events for the work, so a customer who gets things done stands out from one who only looked in.

Send the important ones from your server#

For the handful of events Oskar's decisions depend on, send them from your server when the action is saved. Server events arrive every time, whatever a browser or ad blocker does:

posthog.capture(
    distinct_id=user.id,
    event='invoice_sent',
    properties={'$set': {'email': user.email}},
)

Including $set with the email keeps the person identified from the server too.

3. Tell Oskar which events matter#

During setup, Oskar looks at every event seen in the last 28 days, works out how many customers use each one and how often, and suggests:

  • Actions that show real value. Two to five events that mean a customer is getting value, not just visiting. Oskar uses these to notice when a customer stops using the features that matter, even while they still log in.
  • A new customer is set up once they have… The single action that shows a new customer has got going. Oskar checks it for every customer in their first 30 days and on trial, and flags those who have not reached it.

You confirm or change these in the setup conversation, and later under Settings → What Oskar knows, where the pickers list every event Oskar has seen. The list fills in as your product sends events: a new event appears the day after someone first triggers it.

Oskar also asks how often healthy customers use it: every working day, a few times a week, or a few times a month. This sets how long a quiet spell can last before it means something. Three days of silence is nothing for a monthly reporting tool and a lot for a daily one.

Checking it worked#

  • Integrations shows when Oskar last read PostHog. It runs every night at 02:30 UTC and assesses customers at 03:00 UTC. After changing your tracking, give it a night, or choose Reassess now on Today once the sync has run.
  • Customers can be filtered to No product usage reported. These are paying customers with no usage matched to them yet. If the list is longer than you expect, check that those people are identified by the email they pay with, and that the matching rule suits your business.
  • A customer's page shows their usage over twelve weeks and which events they trigger. Compare it with a customer you know well and it should match what you would expect.
  • Settings → What Oskar knows lists the events Oskar has seen under the key-event and set-up pickers.

Oskar reads the last 28 days, so new tracking shows up within a day and there is nothing to backfill.

Next

For AI tools: this page is also available as Markdown, and every page is listed in llms.txt.