Revenue Tracking
Swetrix integrates with Stripe and Paddle to automatically track your revenue alongside your analytics data. Once connected, you can see revenue trends, refunds, and per-user attribution directly in your traffic dashboard — no code changes required.
How it works
- You connect your payment provider (Stripe or Paddle) in your project settings.
- Swetrix syncs your transaction data every 30 minutes using read-only API access.
- Revenue appears as a metric in your Traffic Analytics chart, broken down by the same time periods and filters you already use.
Revenue is displayed as stacked bars on the chart: net revenue in solid orange, with refunds overlaid on top.
Supported providers
| Provider | Connection method | Transaction types |
|---|---|---|
| Stripe | Restricted API key (read-only) | Sales, subscriptions, refunds |
| Paddle | API key | Sales, subscriptions, refunds (adjustments) |
Setting up Stripe
- Go to your project dashboard and open Project Settings > Revenue.
- Select Stripe as the provider.
- Create a restricted API key in your Stripe dashboard. Swetrix needs the following read-only permissions:
- Charges, Subscriptions, Customers, Payment Intents, Checkout Sessions, Invoices, Products (read)
- Webhooks (write — for real-time sync)
The settings page includes a direct link to create a Stripe restricted key with the correct permissions pre-selected — just click "Create key on Stripe" and confirm.
- Paste the restricted key (starts with
rk_live_) into the API key field. - Choose your preferred display currency (USD, EUR, or GBP). Swetrix will convert all transactions to this currency automatically.
- Click Connect.
Setting up Paddle
- Go to your project dashboard and open Project Settings > Revenue.
- Select Paddle as the provider.
- Generate an API key in your Paddle dashboard with the following permissions:
- Transactions, Subscriptions, Customers, Products, Prices (read)
- Paste the API key (starts with
pdl_live_) into the API key field. - Choose your display currency and click Connect.
Viewing revenue data
Once connected, a Revenue metric becomes available in the Traffic Analytics chart. Toggle it on using the metric selector above the chart.
The chart displays:
- Revenue — total net revenue for each time bucket (hour, day, week, etc.)
- Refunds — refund amounts stacked on top for visual comparison
You can combine revenue with any other metric (pageviews, sessions, etc.) and use all standard dashboard features: date ranges, comparisons, filters, and segments.
User attribution
Swetrix can attribute revenue to specific visitors using profile IDs. This lets you see which users generated revenue and connect purchases to browsing sessions.
How attribution works
When Swetrix syncs transactions, it looks for a swetrix_profile_id field in the transaction metadata:
- Stripe: checks
metadata.swetrix_profile_idon the PaymentIntent or Charge - Paddle: checks
custom_data.swetrix_profile_idon the Transaction
If found, the transaction is linked to that visitor's profile in the Profiles & Sessions view.
Passing the profile ID to your payment provider
First, get the visitor's profile ID using the Swetrix script:
const profileId = await swetrix.getProfileId();Then include it when creating a payment:
Stripe example (server-side):
const paymentIntent = await stripe.paymentIntents.create({
amount: 2000,
currency: "usd",
metadata: {
swetrix_profile_id: profileId,
},
});Paddle example (client-side checkout):
Paddle.Checkout.open({
items: [{ priceId: "pri_xxxxx", quantity: 1 }],
customData: {
swetrix_profile_id: profileId,
},
});You can also pass swetrix_session_id (from getSessionId()) to attribute revenue to a specific browsing session.
See the Script Reference for full details on
getProfileId() and getSessionId().
Managing your connection
You can disconnect or change your payment provider at any time from Project Settings > Revenue. Disconnecting removes the API key but keeps previously synced revenue data in your dashboard.
To change the display currency after connecting, use the currency selector on the same settings page. Currency conversion is applied to all transactions (past and future) based on exchange rates at sync time.
Help us improve Swetrix
Was this page helpful to you?
