Payment Tracking
Automatically track Stripe payments and attribute revenue to marketing channels.
Automatic Detection
TwoBucks automatically detects Stripe checkout sessions when users complete a payment. One configuration step is required - you must include the session ID in your success URL.
How It Works
- Customer completes Stripe checkout
- Stripe redirects to your success page with
?session_id=cs_xxx(if configured) - TwoBucks detects the session ID and sends a payment event
- Revenue is automatically attributed to the marketing channel
Success Page Setup
Ensure your Stripe success page includes the tracking script:
<!DOCTYPE html>
<html>
<head>
<title>Payment Successful</title>
<script
src="https://www.twobucks.ai/script.js"
data-website-id="your-website-id"
async
></script>
</head>
<body>
<h1>Thank you for your purchase!</h1>
</body>
</html>Stripe Configuration
⚠️ Required: Include Session ID in Success URL
You MUST include {CHECKOUT_SESSION_ID} in your success_url for payment tracking to work.
Checkout Session Redirect
When creating your Stripe checkout session, include the session ID placeholder in your success URL:
const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
line_items: [...],
mode: 'payment',
success_url: 'https://yoursite.com/success?session_id={CHECKOUT_SESSION_ID}',
cancel_url: 'https://yoursite.com/cancel',
});The {CHECKOUT_SESSION_ID} placeholder is automatically replaced by Stripe with the actual checkout session ID.
Revenue Attribution
Revenue is automatically attributed to the marketing channel that drove the traffic.
How It Works
- Referrer Preservation: The tracking script captures and stores the referrer (e.g., "google.com")
- Stripe Redirect: User goes through Stripe checkout
- Payment Detection: After payment, script detects the session ID
- Revenue Attribution: Backend matches payment events to Stripe charges and attributes revenue
Manual Tracking
If you need to track payments manually (e.g., for non-Stripe payments):
window.twobucks('payment_completed', {
amount: 99.99,
currency: 'USD',
order_id: 'order-123'
});Stripe Integration
To see revenue in your dashboard:
- Go to Website Settings
- Click "Connect Stripe"
- Enter your Stripe API key (read-only permissions required)
Required Permissions
- charges:read
- invoices:read
- subscriptions:read
- checkout.sessions:read