Skip to main content

What It Is

Customers who arrive via a creator link shouldn’t lose their discount. Maintained discount protection ensures the code persists across sessions, page navigations, and checkout flows.
Enable Safe Discount Codes in Settings → Discount Settings to protect your base discount codes from coupon scrapers while providing unique codes per checkout.

Key Capabilities

  • Session persistence — Discount survives page refreshes
  • Cross-device hints — Email links include discount
  • Auto-application — Code applied at checkout automatically
  • Stacking rules — Define how creator discounts interact with promos
  • Expiration handling — Graceful fallback when codes expire
  • Safe discount codes — Unique codes per checkout protect base discounts

Safe Discount Codes

Location: Settings → Discount Settings → Enable Safe Discount Codes What it does:
  • Creates a unique, safe discount code every time someone clicks a creator link and starts checkout
  • Base discount code (e.g., CREATOR20) remains safe and not exposed to coupon code tools
  • Cloned codes are unique per checkout session
  • Base discount stays protected from coupon code scrapers
How it works:
  1. Customer clicks creator link
  2. When checkout starts, a cloned discount is auto-generated
  3. The cloned code is unique (includes random number)
  4. Base discount remains protected
Code template: Configure the format in Settings → Discount Settings → Safe Discount Code Template:
  • Use {FIRSTNAME}, {LASTNAME}, {DISCOUNT} variables
  • Example: {FIRSTNAME}{DISCOUNT}SARAH20 + random → SARAH201234
  • Random number always appended for uniqueness
When to enable:
  • You want to protect base discount codes from coupon scrapers
  • You need unique codes per checkout for tracking
  • You’re not using an affiliate platform that already handles this
When to disable:
  • You’re using an affiliate platform with built-in discount protection
  • You want to use the base discount code directly
  • You have custom discount management logic

Initial Settings Guide

Complete guide to configuring safe discount codes and discount settings

Protection Layers

LayerMethodPersistence
URL parameter?discount=CODESingle page
Cart attributescc-discount-codeCart session
Local storagecc_discount_code30 days
Checkout URL/checkout?discount=CODECheckout
Email linksPre-applied in URLsPer-click

Implementation

{% comment %} On every page {% endcomment %}
{% if cart.attributes['cc-discount-code'] == blank %}
  {% assign stored_code = request.params['discount'] %}
  {% if stored_code %}
    <script>
      fetch('/cart/update.js', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({
          attributes: { 'cc-discount-code': '{{ stored_code }}' }
        })
      });
    </script>
  {% endif %}
{% endif %}

Checkout Auto-Apply

// Before redirect to checkout
const discountCode = cart.attributes['cc-discount-code'];
if (discountCode) {
  window.location.href = `/checkout?discount=${discountCode}`;
}

Edge Cases Handled

ScenarioSolution
Customer clears cookiesEmail links restore discount
Code expires mid-sessionShow notification + alternative
Multiple codes enteredLast code wins or best-of
Checkout timeoutDiscount re-applied on return

How This Connects