Log Stripe subscription cancellations to Amplitude and a churn sheet

By General Input

The moment a Stripe subscription cancels, record a churn event in Amplitude and add a row to your finance and CS churn tracker sheet.

Integrations

  • Stripe
  • Amplitude
  • Google Sheets

Type

Deterministic Code

Categories

  • Product
  • Finance

Whenever a Stripe subscription is canceled, I want to ingest a matching churn event into Amplitude and log the cancel to a churn tracker Google Sheet. Every step is deterministic and no LLM reasoning is needed.

Trigger: a Stripe webhook on the customer.subscription.deleted event. When Stripe fires the webhook, read the payload and pull the subscription's customer email, plan name (or price nickname), MRR (in the smallest currency unit converted to a number), the subscription start date, and the cancellation reason from cancellation_details.reason (falling back to canceled_at or an empty string when it is missing). Also capture the Stripe event id and the canceled_at timestamp.

Step 1: call Amplitude's Send Events (HTTP V2) operation to record a single event. Use the customer email as user_id, event_type set to a configurable event name that defaults to "Subscription Canceled", the canceled_at time as the event time, and event_properties containing plan, mrr, start_date, cancellation_reason, and stripe_subscription_id. Use the Stripe event id as insert_id so retries dedupe safely on Amplitude's (device_id, event_type, time, insert_id) key.

Step 2: call Amplitude's Identify (Update User Properties) operation for the same user_id, setting is_churned=true, churned_at=canceled_at (ISO 8601), churn_mrr=MRR, and last_plan=plan. This is a user-property update only, not a second event.

Step 3: call Google Sheets Append Values on a configurable Sheet ID and tab (default "Churn Log"), appending one row in this column order: customer email, plan, MRR, tenure in days (canceled_at minus start_date, rounded down), cancellation reason, and ISO 8601 timestamp. Use valueInputOption USER_ENTERED so the timestamp and numbers are parsed correctly.

Expose two knobs on the prompt page: the Amplitude event name (default "Subscription Canceled") and the Google Sheet spreadsheet ID plus tab name. Respect Amplitude data residency when configured. If the webhook payload lacks an email, skip the row and the event rather than sending a blank user_id.

Related prompts

Explore more prompts
Call overdue Xero customers with an AI collections agentLocal listing health board for every location you manageLet support send one-off Loops emails without an engineerStop cold emails to anyone with a live deal in PipedriveCustomer lifecycle inspector for Loops, Stripe and PostHogiMessage campaign console with pre-flight checks and delivery boardLinkedIn Ads budget pacing dashboard for every client accountFront desk appointment confirmation board for the next 3 daysGive your team Looker numbers without buying more seatsBuild audience segments from product usage and push to Loops