# Measure referral quality, not just invites

> Track invite sent, invite accepted, activation, and retention so product teams know whether referrals create valuable users.

## Agent adaptation contract

- Canonical human page: https://agentry.sh/workflows/referral-quality-loop
- Execution mode: on_demand
- Immutable automation template: none
- Applies to: b2c-saas, b2b-saas, marketplace, games
- Required example events: referral_invite_sent, referral_invite_accepted, activated
- Required Agentry resources: none declared
- Do not use when:
  - Do not use until the example events are mapped to observed project signals, the current onboarding state is verified, and live event/property reads prove the required data is present.
- Ask before using:
  - Which observed events map to referral_invite_sent, referral_invite_accepted, activated? Is the current onboarding state verified, and do live event/property reads show non-synthetic traffic for them?
  - Which live properties provide referral_invite_sent.inviter_id, referral_invite_sent.channel, referral_invite_accepted.inviter_id, referral_invite_accepted.invitee_id, activated.source, and which stable user or account identifier joins the signals?

This is an adaptable workflow example, not an API recipe. Map event and property names to the project's saved signal map, require status: "verified" from GET /v1/projects/:project_id/onboarding, and confirm the required signals through live event/property metadata and rows. Fetch current OpenAPI or query-blueprint details before making calls. Do not infer unattended authority from this page.

## Why this matters

Referral programs can inflate signup volume without producing retained users. Quality matters more than invite count.

## What you get

- Invite send and acceptance rates
- Activation and retention of referred users
- Best inviter cohorts and channels
- Whether referral rewards are attracting quality users

## Walk through it

**You:**
> Are referrals bringing good users?

**Agent:**
> I'll follow referred users from invite to activation.

```text
Endpoint: POST /v1/projects/:project_id/analytics/query
Exact shape: /v1/openapi.json?path=%2Fv1%2Fprojects%2F%7Bproject_id%7D%2Fanalytics%2Fquery&method=post
Custom HogQL goes in the OpenAPI-defined `query` field.
Concept fields:
  query: "SELECT properties.channel AS channel, countIf(event = 'referral_invite_sent') AS sent, countIf(event = 'referral_invite_accepted') AS accepted, countIf(event = 'activated') AS activated FROM events WHERE event IN ('referral_invite_sent','referral_invite_accepted','activated') AND timestamp > now() - INTERVAL 60 DAY GROUP BY channel ORDER BY accepted DESC"
```

## The output

The agent returns referral channels and inviter cohorts ranked by activation quality.

## Setting it up

Emit referral lifecycle events with stable inviter and invitee identifiers. Preserve referral source onto activation.

## Variations

- *"Show referrals by power-user cohort."*
- *"Find inviters whose referrals activate above average."*
- *"Publish referral quality by channel."*
