Skip to content

Commit

Permalink
New article for Stripe integration
Browse files Browse the repository at this point in the history
  • Loading branch information
SpencerFleury committed Nov 14, 2024
1 parent 3c89d00 commit fad25d1
Show file tree
Hide file tree
Showing 16 changed files with 193 additions and 0 deletions.
141 changes: 141 additions & 0 deletions content/collections/source-catalog/en/stripe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
---
id: 9aa828e6-8ccc-4177-a2eb-1bcd010cb521
blueprint: source-catalog
title: Stripe
this_article_will_help_you:
- 'Set up and use the Stripe integration for Amplitude'
partner_maintained: false
exclude_from_sitemap: false
updated_by: 5817a4fa-a771-417a-aa94-a0b1e7f55eae
updated_at: 1731612715
---
This integration allows you to import revenue events from [Stripe](https://stripe.com/) into Amplitude, enabling seamless tracking and analysis of your Stripe financial data in Amplitude.

{{partial:admonition type='note'}}
This integration is currently in beta and is maintained by Amplitude. For assistance, [contact Amplitude support](https://amplitude.zendesk.com/hc/en-us/requests/new).

Check warning on line 15 in content/collections/source-catalog/en/stripe.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Amplitude.Passive] 'is maintained' looks like passive voice. Raw Output: {"message": "[Amplitude.Passive] 'is maintained' looks like passive voice.", "location": {"path": "content/collections/source-catalog/en/stripe.md", "range": {"start": {"line": 15, "column": 43}}}, "severity": "WARNING"}

Check warning on line 15 in content/collections/source-catalog/en/stripe.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Amplitude.TooWordy] 'assistance' is too wordy. Use a simpler word. Raw Output: {"message": "[Amplitude.TooWordy] 'assistance' is too wordy. Use a simpler word.", "location": {"path": "content/collections/source-catalog/en/stripe.md", "range": {"start": {"line": 15, "column": 75}}}, "severity": "WARNING"}

Check warning on line 15 in content/collections/source-catalog/en/stripe.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Amplitude.ComplexWords] Consider using 'help' instead of 'assistance'. Raw Output: {"message": "[Amplitude.ComplexWords] Consider using 'help' instead of 'assistance'.", "location": {"path": "content/collections/source-catalog/en/stripe.md", "range": {"start": {"line": 15, "column": 75}}}, "severity": "WARNING"}
{{/partial:admonition}}

## Before you begin

* If you have multiple Amplitude projects, you must configure this integration **separately** for each one to ensure accurate event tracking.
* Amplitude **can’t distinguish** between Stripe events from different accounts, because Stripe event payloads don’t include an account identifier. If you connect multiple Stripe accounts to the same Amplitude project, you may experience data duplication and inaccurate revenue reporting.
* This integration **only** records events that occur **after** you configure the Stripe webhook. It doesn’t retroactively capture or send to Amplitude anything that happened before that, so configure it as early as possible.
* Before sending revenue data to Amplitude, **normalize** all financial amounts to your preferred currency. Amplitude doesn’t automatically handle currency conversion, and inconsistent currency reporting could distort revenue insights.
* This integration **only ingests revenue-related** transaction events.
* To avoid tracking inaccuracies, make sure to set `amplitude_id` or `user_id` correctly in the metadata. Otherwise, events from the same user may appear as separate users in Amplitude. **Update your Stripe client** to pass the correct user identifier within the metadata fields for proper event deduplication.

## Set up the integration

1. Log into your Stripe account and navigate to *Developers > Event Destination*.
2. Click *Add Endpoint* to create a webhook.
3. Paste the provided URL into the *Endpoint URL* field to direct data to your Amplitude project.
4. Select API version 2024-06-20 and choose the events you want to ingest into Amplitude.
5. Click *Select Events* to specify the topics you wish to forward to Amplitude. Keep in mind that Amplitude categorizes `payment_intent` as revenue events.
6. Set the correct user ID in your Stripe client code to ensure proper deduplication of user events between Stripe and Amplitude. The integration looks for the user ID in a specific order of priority from the event payload. Make sure the user ID is correctly passed as metadata in the payment intent or other relevant events.

Here is the order in which Amplitude picks up the user ID from Stripe event data:

* `data.object.metadata.amplitude_id`
* `data.object.metadata.user_id`
* `data.object.customer_email`
* `data.object.customer.email`
* `data.object.receipt_email`
* `data.object.customer`

## View Stripe events in Amplitude: Example charts and cohorts

Check warning on line 45 in content/collections/source-catalog/en/stripe.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Amplitude.Headings] 'View Stripe events in Amplitude: Example charts and cohorts' should use sentence-style capitalization. Raw Output: {"message": "[Amplitude.Headings] 'View Stripe events in Amplitude: Example charts and cohorts' should use sentence-style capitalization.", "location": {"path": "content/collections/source-catalog/en/stripe.md", "range": {"start": {"line": 45, "column": 4}}}, "severity": "WARNING"}

Here are some key charts and metrics you can track once you’ve set up the integration.

### Total revenue

1. **Select an event**: Choose the event that tracks successful payments or transactions, such as `[Stripe] invoice.payment_succeeded`.
2. **Set a metric**: Use Property Sum to calculate the total revenue. Set the property to `amount_paid` or another property that stores the revenue amount. This sums the total revenue from all successful payment events.
3. **Apply segmentation**: Choose *All Users* for an overview of total revenue generated by all users who triggered the event from step 1 above.

![stripe_totrev.png](/docs/output/img/sources/stripe_totrev.png)

### Average number of purchases per user

1. **Select an event**: Choose an event that represents a successful transaction or purchase, such as `self-serve: stripe payment intent success` , `Purchase Completed` , or `Order Success`.
2. **Set a metric**: Measure the average number of events per user to track how frequently users are triggering the event.
3. **Apply segmentation**: Choose *All Users* for an overview of all user activity related to that event.

![stripe_appu.png](/docs/output/img/sources/stripe_appu.png)

### Distribution of purchase frequency

1. **Select an event**: Choose an event that tracks successful payments or purchases, such as `[Stripe] invoice.payment_succeeded`.
2. **Set a metric**: Choose *Frequency* to measure how many times users have triggered the selected event.
3. **Set buckets**: Define the buckets to categorize purchase frequency. This helps visualize how many users fall into each frequency category.
4. **Apply segmentation**: Choose *All Users* for an overview of how frequently users are making purchases.

![stripe_dpf.png](/docs/output/img/sources/stripe_dpf.png)

### N-week retention

1. **Select a starting event**: Choose the event that represents a successful transaction or purchase, such as `[Stripe] invoice.payment_succeeded`.
2. **Select a return event**: Choose the same event, or a similar one, to track users who come back to make another purchase.
3. **Set the retention metric**: Select *Return On* to measure retention based on when users return to trigger the same event in specific time windows (for example, weeks). The chart displays retention across multiple weeks (Week 0, Week 1, etc.), showing how many users return after making a purchase in subsequent weeks.
4. **Apply segmentation**: Choose *All Users* for an overview of all users who made a purchase and returned.

![stripe_n_week.png](/docs/output/img/sources/stripe_n_week.png)

### Revenue by product

1. **Select an event**: Choose the event that represents a successful transaction or payment, such as `[Stripe] invoice.payment_succeeded`.
2. **Set a metric**: Use *Property Sum* to calculate the total revenue. Group by the product category or name using the description field (or a similar field) that stores product details. This sums up the total revenue for each product.
3. **Group by product**: Group the results by product name or category to visualize revenue per product.
4. **Apply segmentation**: Choose *All Users* for a breakdown of revenue for all products sold.

![stripe_rbp.png](/docs/output/img/sources/stripe_rbp.png)

### Number of orders by product

1. **Select an event**: Choose the event that represents successful transactions or orders, such as `[Stripe] invoice.payment_succeeded`.
2. **Set a metric**: Use *Uniques* to count the unique occurrences of the event.
3. **Group by product**: Group the data by the product name or description using the *Description* field (or a similar product-related field). This will break down the number of orders per product.

Check warning on line 96 in content/collections/source-catalog/en/stripe.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Amplitude.Will] Future tense! Avoid using 'will break'. Raw Output: {"message": "[Amplitude.Will] Future tense! Avoid using 'will break'.", "location": {"path": "content/collections/source-catalog/en/stripe.md", "range": {"start": {"line": 96, "column": 149}}}, "severity": "WARNING"}
4. **Apply segmentation**: Choose *All Users* for a complete overview of the number of orders for each product made by all users.

![stripe_obp.png](/docs/output/img/sources/stripe_obp.png)

### Cohort: Users who spent more than $100 in their first seven days

1. **Select users who performed an event**: Choose the event that captures successful transactions, such as `[Stripe] payment_intent.succeeded`.
2. **Set a revenue condition**: Apply a condition where `$revenue > 100` to filter for users who spent more than $100, either in a single transaction or over multiple transactions.
3. **Set a count condition**: Add a condition to ensure the event occurred at least once.
4. **Define the timeframe**: Specify that the transactions must have occurred during the first seven days after the user’s first interaction, or within the last 30 days for more flexible tracking.

Check warning on line 106 in content/collections/source-catalog/en/stripe.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'timeframe'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'timeframe'?", "location": {"path": "content/collections/source-catalog/en/stripe.md", "range": {"start": {"line": 106, "column": 17}}}, "severity": "WARNING"}

![stripe_cohort.png](/docs/output/img/sources/stripe_cohort.png)

## Supported Stripe events in Amplitude

This table lists revenue-related events sent from Stripe to Amplitude. They allow you to track financial transactions such as charges, refunds, invoices, and payments. For more detailed information on the properties associated with each event, [refer to the official Stripe events documentation](https://docs.stripe.com/api/events/types).

| Category | Stripe event | Description |
|----------|--------------|-------------|
| Charges and refunds | `charge.succeeded` | Occurs when a charge is successful. |
| Charges and refunds | `charge.refunded` | Occurs when a charge is refunded, including partial refunds. |

Check warning on line 117 in content/collections/source-catalog/en/stripe.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Amplitude.Passive] 'is refunded' looks like passive voice. Raw Output: {"message": "[Amplitude.Passive] 'is refunded' looks like passive voice.", "location": {"path": "content/collections/source-catalog/en/stripe.md", "range": {"start": {"line": 117, "column": 66}}}, "severity": "WARNING"}
| Charges and refunds | `charge.captured` | Occurs when a previously uncaptured charge is captured. |

Check warning on line 118 in content/collections/source-catalog/en/stripe.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Amplitude.TooWordy] 'previously' is too wordy. Use a simpler word. Raw Output: {"message": "[Amplitude.TooWordy] 'previously' is too wordy. Use a simpler word.", "location": {"path": "content/collections/source-catalog/en/stripe.md", "range": {"start": {"line": 118, "column": 59}}}, "severity": "WARNING"}

Check warning on line 118 in content/collections/source-catalog/en/stripe.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Amplitude.ComplexWords] Consider using 'before' instead of 'previously'. Raw Output: {"message": "[Amplitude.ComplexWords] Consider using 'before' instead of 'previously'.", "location": {"path": "content/collections/source-catalog/en/stripe.md", "range": {"start": {"line": 118, "column": 59}}}, "severity": "WARNING"}
| Charges and refunds | `charge.updated` | Occurs when a charge description or metadata is updated, or upon an asynchronous capture. |
| Charges and refunds | `charge.failed` | Occurs when a failed charge attempt occurs. |
| Invoices | `invoice.payment_succeeded` | Occurs when an invoice payment attempt succeeds. |
| Invoices | `invoice.paid` | Occurs when an invoice payment attempt succeeds or an invoice is marked as paid out-of-band. |
| Invoices | `invoice.finalized` | Occurs when a draft invoice can’t be finalized. See the invoice’s last finalization error for details. |
| Invoices | `invoice.marked_uncollectible` | Occurs when an invoice is marked uncollectible. |
| Invoices | `invoice.payment_failed` | Occurs when an invoice payment attempt fails. |
| Invoices | `invoice.voided` | Occurs when an invoice is voided. |
| Invoices | `invoice.sent` | Occurs when an invoice email is sent. |
| Invoices | `invoice.created` | Occurs when a new invoice is created. To learn how webhooks can be used with this event, and how they can affect it, see Using Webhooks with Subscriptions. |
| Payment intents | `payment_intent.succeeded` | Occurs when a `PaymentIntent` has successfully completed payment. This event is a special `$revenue` event in Amplitude. |
| Payment intents | `payment_intent.canceled` | Occurs when a `PaymentIntent` is canceled. |
| Payment intents | `payment_intent.payment_failed` | Occurs when a `PaymentIntent` has failed the attempt to create a payment method or a payment. |
| Payment intents | `payment_intent.amount_capturable_updated` | Occurs when a `PaymentIntent` has funds to be captured. Check the `amount_capturable` property on the `PaymentIntent` to determine the amount that can be captured. You may capture the `PaymentIntent` with an `amount_to_capture` value up to the specified amount. [Learn more about capturing PaymentIntents](https://docs.stripe.com/api/payment_intents/capture). |
| Checkout sessions | `checkout.session.completed` | Occurs when a checkout session has been successfully completed. |
| Checkout sessions | `checkout.session.async_payment_succeeded` | Occurs when a payment intent using a delayed payment method succeeds. |
| Checkout sessions | `checkout.session.async_payment_failed` | Occurs when a payment intent using a delayed payment method fails. |
| Application fees | `application_fee.created` | Occurs when an application fee is created on a charge. |
| Application fees | `application_fee.refunded` | Occurs when an application fee is refunded, whether from refunding a charge or from [refunding the application fee directly](https://docs.stripe.com/api/events/types#fee_refunds). This includes partial refunds. |
| Application fees | `application_fee.refund.updated` | Occurs when an application fee refund is updated. |
| Balance | `balance.available` | Occurs when your Stripe balance has been updated. By default, Stripe automatically transfers funds in your balance to your bank account on a daily basis. This event is not triggered for negative transactions. |
| Issuing | `issusing_authorization.created` | Occurs when an authorization is created. |
| Issuing | `issusing_transaction.created` | Occurs when an issuing transaction is created. |
3 changes: 3 additions & 0 deletions content/trees/navigation/en/source_catalog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ tree:
-
id: 8b3ab22f-5e49-43fd-a12d-639fa121e407
entry: 54b567aa-96bb-4a2c-8b5a-c61efa012543
-
id: 764aca63-ce14-42f8-995c-604cc600e732
entry: 9aa828e6-8ccc-4177-a2eb-1bcd010cb521
-
id: c1cb4b71-c669-4f87-a8d9-d33fe7efcdf2
entry: 5b361e39-e4a0-4842-965f-e2e73bcc9c19
Expand Down
7 changes: 7 additions & 0 deletions public/docs/output/img/sources/.meta/stripe_appu.png.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data: { }
size: 207630
last_modified: 1731612518
width: 1600
height: 873
mime_type: image/png
duration: null
7 changes: 7 additions & 0 deletions public/docs/output/img/sources/.meta/stripe_cohort.png.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data: { }
size: 116004
last_modified: 1731612518
width: 1600
height: 572
mime_type: image/png
duration: null
7 changes: 7 additions & 0 deletions public/docs/output/img/sources/.meta/stripe_dpf.png.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data: { }
size: 180989
last_modified: 1731612519
width: 1600
height: 876
mime_type: image/png
duration: null
7 changes: 7 additions & 0 deletions public/docs/output/img/sources/.meta/stripe_n_week.png.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data: { }
size: 221403
last_modified: 1731612519
width: 1600
height: 873
mime_type: image/png
duration: null
7 changes: 7 additions & 0 deletions public/docs/output/img/sources/.meta/stripe_obp.png.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data: { }
size: 193223
last_modified: 1731612520
width: 1600
height: 876
mime_type: image/png
duration: null
7 changes: 7 additions & 0 deletions public/docs/output/img/sources/.meta/stripe_rbp.png.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data: { }
size: 209989
last_modified: 1731612520
width: 1600
height: 876
mime_type: image/png
duration: null
7 changes: 7 additions & 0 deletions public/docs/output/img/sources/.meta/stripe_totrev.png.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data: { }
size: 223996
last_modified: 1731612521
width: 1600
height: 876
mime_type: image/png
duration: null
Binary file added public/docs/output/img/sources/stripe_appu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/docs/output/img/sources/stripe_cohort.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/docs/output/img/sources/stripe_dpf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/docs/output/img/sources/stripe_n_week.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/docs/output/img/sources/stripe_obp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/docs/output/img/sources/stripe_rbp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/docs/output/img/sources/stripe_totrev.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fad25d1

Please sign in to comment.