Complete end-to-end guide to attributing monetary revenue (amount), calculating EPC and ROI, capturing clickId across checkout funnels, and handling multi-currency purchases and refunds.

The LShorter Financial Conversion Engine provides exact, end-to-end monetary attribution by linking e-commerce revenue (amount) directly to the originating short link click (clickId). Whether you sell via Stripe, Shopify, LemonSqueezy, WooCommerce, or a custom checkout funnel, every dollar, euro, or pound is mathematically tied to its acquisition channel.
On the telemetry side, click counters (clicksCount) and conversions (conversionsCount) are incremented lock-free at Cloudflare's Edge. The platform continuously computes critical financial efficiency KPIs: Earnings Per Click (EPC = trackedRevenue / totalClicks), Average Order Value (AOV = trackedRevenue / conversionsCount), and Conversion Rate (CR = conversionsCount / totalClicks * 100).
The system natively handles multi-currency normalization (USD, EUR, GBP, CAD, JPY), partial or full refund deductions (POST /api/v1/track/refund) to keep financial reports clean, and delayed asynchronous payments.
Core architectural pillars ensuring high performance, isolation, and security.
Ready-to-use TypeScript code snippets and configuration examples for your integrations.
Add this lightweight snippet to your website's <head> or footer to automatically capture the clickId from the URL and persist it in a 30-day cookie and localStorage:
React hook to capture the clickId from Next.js useSearchParams and persist it across client routing:
Pass clickId and customer details into Stripe Checkout Session metadata, then attribute revenue upon payment in your webhook handler:
Attributing orders created in Shopify store back to LShorter short links with customer avatar:
Extract customer profile images from Google/GitHub OAuth, NextAuth, Clerk, or Gravatar and supply them to LShorter:
Deduct refunded amounts from cumulative link revenue to maintain accurate financial telemetry:
Read atomic click counters, cumulative revenue, AOV, and calculate campaign ROI:
Direct HTTP request methods, parameters schema, authentication, and responses.
Records a completed purchase, subscription, or conversion event with revenue amount, currency, and customer details attributed to a specific clickId.
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| Authorization | string | Required | Bearer token containing your API key. | Bearer lsho_live_89f023ab912 |
| Content-Type | string | Required | Must be set to application/json. | application/json |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| eventName | string | Required | Name of the conversion event (e.g. purchase, subscription, upsell). | purchase |
| amount | number | Required | Decimal transaction revenue amount collected. | 49.00 |
| currency | string (ISO 4217) | Required | Three-letter uppercase currency code (USD, EUR, GBP, CAD, JPY). | USD |
| clickId | string | Optional | Originating clickId token passed by the short link redirection. | clk_9921ab01 |
| linkId | string | Optional | Short link ID or slug alias if clickId is not available. | link_89f023ab912 |
| orderId | string | Optional | Your internal transaction or invoice ID for deduplication. | ch_9921823ab |
| customer | object | Optional | Customer metadata. | {"email": "alex@example.com", "name": "Alex Johnson", "avatarUrl": "https://example.com/photos/alex.jpg"} |
| customer.email | string (email) | Optional | Customer email address for LTV attribution. | alex@example.com |
| customer.name | string | Optional | Customer full name. | Alex Johnson |
| customer.avatarUrl | string (url) | Optional | Avatar image URL displayed in telemetry dashboards. | https://example.com/photos/alex.jpg |
| customerAvatar | string (url) | Optional | Top-level alias for customer avatar image URL (Gravatar, Google, Discord, GitHub). | https://example.com/photos/alex.jpg |
| metadata | object | Optional | Arbitrary JSON key-value metadata for downstream reporting. | {"plan": "pro_annual", "coupon": "SUMMER30"} |
| HTTP Status | Error Code | Description |
|---|---|---|
| 400 | INVALID_AMOUNT | The amount parameter must be a positive decimal number. |
| 400 | INVALID_CURRENCY | Currency must be a valid 3-letter ISO 4217 uppercase code (e.g. USD, EUR, GBP). |
| 401 | UNAUTHORIZED | Missing or invalid Bearer API key. |
| 404 | CLICK_OR_LINK_NOT_FOUND | Neither clickId nor linkId matched an active record. |
| 409 | DUPLICATE_ORDER_ID | A conversion with this orderId has already been recorded (idempotency protection). |
Deducts a full or partial refund amount from the link's cumulative revenue, adjusting EPC and AOV atomically.
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| orderId | string | Required | The original orderId passed during conversion recording. | ch_9921823ab |
| amount | number | Required | Refunded monetary amount. | 49.00 |
| currency | string (ISO 4217) | Optional | Currency code (defaults to original order currency). | USD |
| reason | string | Optional | Reason for refund (e.g. customer_return, fraud, cancelled). | customer_requested_return |
| refundId | string | Optional | Your payment gateway refund identifier. | re_3Nq2182 |
Retrieves monetary revenue totals, conversion counts, Average Order Value (AOV), and Earnings Per Click (EPC) for a short link.
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| slug | string | Required | Short link slug alias. | summer-sale-2026 |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| period | string (24h | 7d | 30d | 90d | all) | Optional | Timeframe window for financial metrics.Default: 30d | 30d |
| currency | string | Optional | Target currency for display conversion.Default: USD | USD |
Structured JSON response returning atomic visit counts, financial revenue sums, EPC, and customer transactions:
Expert tips to maximize performance, resilience, and link security.
Always store clickId in payment metadata (e.g. Stripe Session Metadata, Shopify Cart Note) so async webhooks and retries never lose attribution.
Pass numeric decimal amounts (e.g. 49.00 rather than 4900 cents) and standard 3-letter ISO uppercase currencies (USD, EUR, GBP).
Subscribe to Stripe charge.refunded or Shopify refunds/create webhooks to call POST /api/v1/track/refund and maintain pristine financial accounting.
Compare your EPC (Earnings Per Click) directly against your CPC (Cost Per Click) to automatically calculate Return on Ad Spend (ROAS).