DashForDevsDocs
DocsNewsAPI v1
dashfordevs.comSign in

© 2026 DashForDevs

DocsNewsdashfordevs.comLegalStatus
DocsAffiliatesTracking Referrals
Introduction
Getting Started
Authentication
Products
Categories
Cart
Checkout
Blog
Reviews
Webhooks
Customers
Orders
Inventory
Shipping
Discounts
Affiliates
Affiliate RegistrationCommission TiersTracking ReferralsPayouts
Email
Media & Files
Analytics & Tracking
Locations
Tax
Global Data
SEO
Error Handling
Geography
Finance
Automations
Page Types
Surveys
Billing & Subscriptions
Storefront Payments
SDK Reference
REST API
Storefront Architecture
Notifications
Security
Team & Permissions
Migrations & Import
Calendar & Appointments
Contact Forms
AI Bots
Dashboard API
Deployment
Changelog
Troubleshooting
Recipes
CLI & Deployment
Image Pipeline
White-label Platforms
Records Engine
Platform Modules
Platform Security
Site Keys & Client Sites
Use Cases
Operations

Tracking Referrals

How affiliate referrals are tracked and attributed.

Updated March 29, 2026

On this page
  • Overview
  • Referral Link Validation
  • Referral Dashboard
  • Implementing Referral Links
  • REST API
  • Next Steps

Overview

Referrals are tracked automatically when a customer uses an affiliate's discount code at checkout. The affiliate receives credit for the sale.

Referral Link Validation

typescript
import dash from "@/lib/dash"

const result = await dash.referrals.validate({
  secret: "ref_abc123",  // referral secret from URL
  subtotal: "99.99",
})

// result = {
//   valid: true,
//   referrer_first_name: "John",
//   code: "JOHNS-REF",
//   is_percentage: true,
//   rate: "15",
//   discount_amount: "15.00",
//   meetsMinimum: true
// }

Referral Dashboard

typescript
// Authenticated customer
const dashboard = await dash.referrals.dashboard()

// dashboard = {
//   referral_secret: "ref_abc123",
//   referral_link: "https://yourstore.com/?ref=ref_abc123",
//   total_referrals: 12,
//   total_points_earned: 600,
//   points_balance: 250,
//   recent_referrals: [...]
// }

Implementing Referral Links

typescript
// On storefront, check for referral param in URL
const ref = new URLSearchParams(window.location.search).get("ref")
if (ref) {
  // Store the referral secret for checkout
  localStorage.setItem("referral_secret", ref)

  // Validate and auto-apply discount
  const result = await dash.referrals.validate({
    secret: ref,
    subtotal: cartSubtotal,
  })

  if (result.valid) {
    await dash.cart.applyDiscount(result.code)
  }
}

REST API

shell
# Validate referral
POST /storefront/referrals/validate
Content-Type: application/json
{ "secret": "ref_abc123", "subtotal": "99.99" }

# Referral dashboard (authenticated)
GET /storefront/referrals/dashboard
Authorization: Bearer {access_token}

Next Steps

  • Payouts — Affiliate payouts
  • Customer Points — Points from referrals
PreviousCommission TiersNextPayouts

On this page

  • Overview
  • Referral Link Validation
  • Referral Dashboard
  • Implementing Referral Links
  • REST API
  • Next Steps