Sprusify

Coupon & Discount Integration

Coupon codes provide a reliable method to attribute sales to affiliates, especially when customers switch devices. This page explains recommended patterns and integration notes.

When to use coupons

  • Use coupon attribution when you expect conversions to happen across devices or when strict privacy settings block cookies.
  • Use unique codes per affiliate or per campaign for precise attribution.

Implementation patterns

  • Single-use affiliate codes: generate unique codes for high-value, limited promotions.
  • Persistent affiliate codes: assign a code to each affiliate that can be used repeatedly.

Shopify setup

  • Create discount codes in Shopify (manual or via API) and store the mapping to affiliate_id in Sprusify.
  • When a discount code is used at checkout, the Shopify order webhook will include the discount code for attribution.

Edge cases & rules

  • Code sharing: if affiliates share codes, attribute to the affiliate who owns the code; monitor unusual usage spikes.
  • Stacked discounts: define rules for whether affiliate commissions apply on pre-discount or post-discount totals.

Reconciliation & reporting

  • Include the discount code in exports so finance teams can match orders to affiliates.
  • Reconcile refunds and code reversals to adjust affiliate balances.

Developer notes

  • Validate discount code presence on orders/create webhook and run attribution logic synchronously.
  • For bulk code creation, use Shopify API rate limiting best practices and store a mapping table with discount_code -> affiliate_id.

Using coupons alongside cookies increases attribution coverage and reduces lost conversions.

  • Each affiliate can have a unique coupon code or a coupon prefixed by their ID.
  • When an order uses a coupon linked to an affiliate, the order is attributed immediately to that affiliate.

Implementation steps

  1. Create a coupon template in the app (Admin > Coupons > New Coupon).
  2. Assign the coupon to an affiliate or a campaign.
  3. Publish the coupon (Shopify discount is created automatically for connected stores).

Testing

  • Place a test order using the coupon code and confirm the affiliate is credited in Transactions.

Edge cases & tips

  • If multiple coupons or links are used, coupon attribution typically takes priority over an expired tracking cookie.
  • For stackable discounts, verify Shopify’s discount priority settings to ensure correct totals.