Help

How to sync discount codes between Shopify and Nudgesmart

Generate, fetch, and auto-apply Shopify discount codes inside your Nudgesmart popups — with per-visitor uniqueness, expiration, and customer binding.

Nudgesmart turns every popup conversion into a real Shopify discount code — created on demand, bound to the visitor, expiring on your schedule, and ready to auto-apply at checkout.

TL;DR

Open your campaign, switch on Enable automatic discount generation in the Discounts tab, choose a Discount Type (Percentage Off, Fixed Amount, or Free Shipping), set the value, prefix, expiration, minimum order, and usage limit, then publish. When a shopper converts — by entering their email, spinning the wheel, picking a present, or scratching a card — Nudgesmart creates a real, single-use Shopify discount code, ties it to that customer's email, copies it to their clipboard, and (optionally) sends them straight to checkout with the code pre-applied. No CSV imports, no manual code generation, no leaked codes.

Static codes, dynamic codes, and pre-created codes — which to use

You have three patterns to choose from, and the right one depends on how much abuse risk you're willing to absorb.

Static codes are one fixed code that everyone sees — WELCOME10, SUMMER20, BFCM2026. Easiest to set up: paste the code into the popup's coupon element and you're done. The catch: codes leak. Once one shopper screenshots WELCOME10 and posts it to a deals subreddit, every visitor uses it whether they earned it or not. Use static codes for site-wide promotions where leakage is the point — Black Friday, holiday sales, public influencer codes — not for popup-gated offers.

Dynamic per-visitor codes are what Nudgesmart generates by default when you switch on automatic discount generation. Each shopper gets a unique code like SPIN_A8X9F2 or NUDGE_K3M2P9 that's tied to their email address inside Shopify. If they share it, Shopify rejects the second redemption. Use dynamic codes for any value-exchange popup: email capture, spin-the-wheel, pick-a-present, scratch-and-win. This is the right default for almost every merchant.

Pre-created bulk codes are codes you generate in advance from Shopify Admin → DiscountsCreate discount → bulk-code import. You'd then map them into static popups one batch at a time. The Shopify Help Center explains how at help.shopify.com/manual/discounts. This pattern fits niche cases — printed direct-mail campaigns where the code has to be known in advance — but for storefront popups, dynamic generation does the same job with less setup.

How to connect Nudgesmart to Shopify's Discounts API

Connection is automatic. When you installed Nudgesmart, you approved the write_discounts scope (it's in the permissions list during install — see the Nudgesmart install guide for the full scope reference). That single scope is what lets Nudgesmart create, update, and expire codes on your behalf via Shopify's Admin API.

Open the Campaigns page, click into any campaign, and switch to the Discounts tab. You'll see a single checkbox — Enable automatic discount generation — with the helper text "When enabled, the system will automatically create Shopify discount codes." Tick it, and the configuration panel reveals itself.

For Spin Wheel and Pick-A-Present campaigns, defaults you set here apply to every winning segment that doesn't have its own discount value configured in the Segments panel. For Email Capture and Multi-Step popups, these defaults govern the code that gets sent when a shopper subscribes.

How to pick a code in the popup editor

Once discounts are enabled, the Discounts tab exposes the seven fields that govern every code Nudgesmart will generate:

  • Default Discount Type — Percentage Off, Fixed Amount ($), or Free Shipping. Free Shipping uses Shopify's dedicated free-shipping mutation, so the value field hides automatically.
  • Default Discount Value — your percentage (1-100) or dollar amount. Used as the fallback when a wheel segment or present doesn't define its own.
  • Code Prefix — three-to-ten letters that lead every generated code. Defaults are SPIN for wheel campaigns and NUDGE for email captures, but you can override to anything alphanumeric. Each visitor's code looks like <PREFIX>_<8-random-chars>.
  • Expiration (minutes) — how long the code stays valid. Anywhere from 5 minutes (urgent close-the-sale moment) to 30 days. Most merchants land around 30-60 minutes.
  • Minimum Order Amount — set this to enforce a cart-value threshold before the code applies. 0 means no minimum.
  • Usage Limit — total redemptions allowed for the generated code. Default is 1.
  • Applies once per customer — checked by default. With this on, the code is bound to the converting shopper's Shopify customer record by email — they can use it once, no one else can use it. Uncheck only if you want the code transferable.

For per-segment control on Spin Wheel campaigns, the Segments panel lets you override discount type, value, and prefix per segment — so your "20% off" wedge can fire a different code than your "Free shipping" wedge while sharing the campaign's expiration and usage rules.

How to auto-apply the code at checkout

Shopify supports a checkout-pre-fill URL pattern: https://yourstore.com/discount/CODE?redirect=/cart (or /checkout) drops the shopper into a cart or checkout with the code already applied. Nudgesmart populates this URL automatically.

When a shopper converts, Nudgesmart writes the generated code into a data-coupon-display="true" element in the popup so the shopper sees it immediately, copies it to the clipboard with a single tap of the Copy button, and — if the popup includes a Shop now or Apply discount button — wires the discount-URL pattern into that button so one click takes the shopper to checkout with the code locked in. No typing, no screenshots, no friction.

If you want shoppers to apply the code manually (some merchants prefer this for measurable redemption tracking), uncheck the Shop now button or replace it with a non-discount link. The code still copies, the shopper still sees it, but checkout is left alone.

How to avoid duplicates and stacking issues

Shopify's default behaviour is one discount code per cart — a second code overwrites the first. Merchants who want stacking have to opt in by configuring combineable discounts in Shopify Admin → Discounts → Settings. The Shopify documentation walks through which combinations are allowed (product + shipping, order + shipping, etc.) at shopify.dev's DiscountCode object reference. If you're not sure, default to non-stacking — it's the safer choice for offer integrity.

Three more housekeeping items worth getting right:

  • Single-use codes auto-archive on redemption. With Usage Limit = 1 (the default), Shopify disables the code immediately after the shopper checks out. If they try to use it again, they'll see "Code expired." Set the usage limit to a higher number only if you genuinely want a single code reusable across multiple orders.
  • Customer binding prevents code-trading. With Applies once per customer on, sharing the code on Reddit doesn't help anyone — Shopify rejects redemptions from any other customer's email. Leave this on unless you're running a friend-referral mechanic.
  • Expirations create urgency. A 30-minute expiration converts dramatically better than a 7-day one because loss aversion is real. The code is bound to the customer, so there's no abuse risk in being aggressive here.

You can browse all the codes Nudgesmart has generated for your store inside Shopify Admin → Discounts at any time. Each carries the title Nudgesmart <campaign-name> Discount, the campaign name in the title makes filtering trivial.

Common pitfalls

  • Discount creation succeeds but customer-email lookup fails. Logs show "Customer not found by email" and the code is created without a customer restriction. This happens when the email capture record hasn't synced to Shopify yet (rare, but possible on free Shopify plans during backfills). Workaround: enable Applies once per customer explicitly and Nudgesmart will bind to the freshly-created customer record.
  • Free Shipping codes ignore the discount value field. Free Shipping uses a different Shopify mutation that doesn't accept a value — Nudgesmart hides the field automatically, but if you toggle from Percentage Off → Free Shipping with a value still set, that value is ignored, not erroneous.
  • Codes expire mid-checkout. A 5-minute expiration plus a slow shopper plus a broken phone keyboard equals "Code expired" frustration. Default to 30+ minutes for live campaigns; reserve sub-15-minute timers for genuine flash-sale teasers paired with countdowns.
  • Bulk-import codes from Shopify don't sync back to Nudgesmart's analytics. If you create codes in Shopify Admin and use them as static codes inside Nudgesmart, redemption tracking falls back to Shopify's reporting. Use dynamic codes whenever you care about per-popup attribution.

FAQ

Can I use the same code prefix across multiple campaigns?

Yes. Prefixes are not unique per campaign — BFCM can prefix codes from your homepage exit-intent popup AND your cart-abandonment campaign. Each generated code's 8-character random suffix guarantees uniqueness inside Shopify.

What happens to existing customer accounts when a code is bound to them?

Nothing visible. The Shopify customer record stays the same; the discount is added to the customer's assignedCustomers array on the discount node. Customers don't see "you have an unused code" in their Shopify account — they see the code in the popup at the time of conversion.

Do generated codes count against my Shopify plan's discount limit?

Shopify's per-store discount limits are very high (200+ active codes on most plans) and active codes drop off automatically when they expire or hit their usage cap. For typical popup volume, you'll never come close. If you run a large store with hundreds of daily conversions, talk to Shopify Plus for the higher tiers.

Can I refund a discount code if a shopper abuses it?

Codes themselves can't be "refunded," but you can disable a specific generated code at any time from Shopify Admin → Discounts → click the code → Deactivate. The code stops working immediately on the storefront and at checkout.

Can I see which campaign generated which code?

Yes. Every generated code is titled Nudgesmart <campaign-name> Discount (e.g., Nudgesmart Welcome Popup Discount). Filter the Shopify Discounts page by title to see redemptions per campaign. For deeper attribution by visitor, the Nudgesmart Analytics tab shows code-redemption events per campaign.

If you also want emails from your popups flowing into Klaviyo lists alongside the discount codes, see how to connect Klaviyo to Nudgesmart — they work together. And the full Nudgesmart /integrations marketing page lists every tool that talks to Nudgesmart out of the box.