Store-Native Discount Code Minting
MailInApp supports dynamic Store-Native Discount Code Minting for connected Shopify and WooCommerce stores.
Rather than forcing buyers through a third-party checkout or generic public coupons, MailInApp automatically mints single-use, customer-restricted discount codes directly on your store at send time — through either of two independent mechanisms, which a single project can use together, separately, or not at all:
- Project-level Discount offer — a Send-page setting that mints one code per matched recipient, scoped to your whole store or to one product picked from a dropdown, meant to pair with a Purchase history audience segment. See Discount offer.
- Per-product Product block discount — a toggle on the Studio Product block itself, scoped to exactly whichever item that block imported from your catalog, needing no audience filter or Send-page setup at all. Walked through end to end in Per-product discount codes for Shopify and WooCommerce.
Both mint through the same underlying store connection and share the mechanics below; a per-product discount just additionally restricts the code to one item and keeps its own cooldown marker, separate from the project-level offer's and from every other Product block's.
How It Works
When a campaign or journey includes a discount offer:
- Dynamic Customer Resolution:
- Shopify: Resolves the recipient's customer GraphQL ID (
gid://shopify/Customer/...) via Admin GraphQL before generating the discount node. - WooCommerce: Restricts the generated coupon to the recipient's exact email address using WooCommerce REST API.
- Shopify: Resolves the recipient's customer GraphQL ID (
- Single-Use & Secure:
- Codes carry random cryptographic suffixes (e.g.
MIA-7F3A91B2). - Every code is restricted to a single use (
usage_limit: 1) and tied exclusively to the recipient's email address, preventing coupon leakage on deal sites. The one exception is a WooCommerce code for one product that opens a checkout link: it stays single-use, limited to that product and short-lived, but isn't tied to the email, because WooCommerce drops an email-locked coupon from a checkout link before the shopper has entered their email.
- Codes carry random cryptographic suffixes (e.g.
- Optional Product Scoping:
- A code minted store-wide applies to any purchase. One scoped to a product — the project-level offer's own Scope picker, or a Product block's per-product discount — is restricted to just that item: Shopify via
customerGets.items.products.productsToAddon a real Product GID, WooCommerce via the coupon'sproduct_idsfield.
- A code minted store-wide applies to any purchase. One scoped to a product — the project-level offer's own Scope picker, or a Product block's per-product discount — is restricted to just that item: Shopify via
- Store Checkout Pre-Application:
- A store-wide or project-scoped code's link opens your store with the code: Shopify applies it (
/discount/MIA-...redirecting to/); WooCommerce has no link that applies a code to an empty cart, so its link (/cart/?coupon=MIA-...) opens the cart and the shopper enters the code, which the email shows, at checkout. - A Product block's own per-product discount instead lands the shopper on that one product with the code already applied. On Shopify it's the product's own page (
/discount/MIA-...?redirect=<product path>). On WooCommerce 10 or later it's a checkout link (/checkout-link/?products=<id>:1&coupon=MIA-...) that puts the product, or the variation the shopper picked, in the cart and opens checkout with the coupon applied. An older WooCommerce store gets the product page with?coupon=MIA-..., and the shopper enters the code at checkout.
- A store-wide or project-scoped code's link opens your store with the code: Shopify applies it (
- Visible Before the Shopper Clicks Through:
- The Studio canvas shows the same discount badge and struck-through price as the mailed email and Live view the moment you turn on a Product block's per-product discount — no need to open Live view to check it.
- For Shopify stores, an optional discount badge shows that same badge directly on the live product page for a shopper who clicked through from the email, ahead of checkout — see Showing the discount on your product page (Shopify) below for setup. There's no WooCommerce equivalent — WooCommerce coupons have no mechanism for changing what a product page itself displays.
Showing the discount on your product page (Shopify)
The Studio canvas already shows the discount badge and struck-through price the moment you turn on a Product block's per-product discount — no setup needed. Putting that same badge on your live Shopify storefront is a one-time, manual step per store, since MailInApp never edits your theme automatically. You paste a short piece of code into your product page; there's nothing to install:
- In MailInApp, go to Settings → Integrations. On your Shopify store's card, open Show the discount on your product pages and click Copy code.
- In Shopify Admin, go to Online Store → Themes and click Customize on your live (or a draft) theme.
- Switch the page picker at the top to a Product page.
- In the Product information section, click Add block (not "Add section") and choose Custom Liquid.
- Paste the code into the block's Liquid code box, drag the block under the price, then Save.
The code loads the badge from mailinapp.com and reads the product's prices from your theme, so it shows the price of the size or colour the shopper has picked, and follows them as they switch. It needs an Online Store 2.0 theme (Dawn and its forks have a Custom Liquid block in their product section).
The badge stays invisible on an ordinary storefront visit by design — it only renders when the product page loads with the signed link a real per-product-discount email produces. So browsing to the page yourself won't show it, and neither will Send test (that renders the email directly and skips the discount-minting step that signs the badge's link). To actually see it, send for real to a recipient — even just yourself — and click Buy now from the delivered email. It's a display-only preview computed from the picked variant's own price; the real discount still only ever applies at checkout via the single-use code either way.
Different rewards per arm
An experiment can give each of its arms its own store offer, so you can test which reward sells more. The codes are minted through the same store connection: one single-use code per recipient, tied to their address, on the store connected to the experiment's contacts list. You set them on the experiment's Reward & attribution step:
- Percentage off, Fixed amount off or Free shipping for each arm. Every arm gets a reward, or none does, and every arm's codes stay valid for the same number of days, so neither offer has longer to work.
- Free shipping is offered to experiment arms only. On Shopify it's a free-shipping code restricted to the recipient. On WooCommerce it's a coupon that grants free shipping, which works only when the store has a Free Shipping method set to require a valid free shipping coupon. The step warns when your store has none.
- No cooldown. An arm's codes skip the cooldown markers above, so every recipient of an arm gets the same offer.
- Shown through merge tags. Put
{{discount_code}}or{{discount_url}}in a block, for example a scratch-off card's prize and link. The lock waits until a block shows the reward. The link also carries the experiment and arm in itsutm_contenttag, for the attribution below. - A code the store can't mint doesn't hold up the send. That recipient's email goes out without the offer, and the results page's Reward codes card counts them per arm.
For free shipping, also enter the Average shipping cost per order. It's counted as promotional cost for each free-shipping order. Test which reward sells more with a scratch-off A/B test walks through a full example.
How orders are matched to arms
Each paid store order is checked against the experiment's Order attribution rules, in a fixed order. The first rule that matches decides the arm, and the rest aren't checked.
Order with the arm's code
- 1Discount codeThe order used the arm's code. The strongest match, even days later.Match
- 2Tracked linkThe buyer arrived through the email's tagged link.Not checked
- 3In-email checkoutBought through a product block's checkout.Not checked
- 4Email address (probable)The buyer's address matches a recipient who clicked during the window. Reported as probable.Not checked
| Step | Rule | Result |
|---|---|---|
| 1 | Discount code | Match |
| 2 | Tracked link | Not checked |
| 3 | In-email checkout | Not checked |
| 4 | Email address (probable) | Not checked |
| Step | Rule | Result |
|---|---|---|
| 1 | Discount code | No match |
| 2 | Tracked link | No match |
| 3 | In-email checkout | No match |
| 4 | Email address (probable) | Match |
- Discount code: the order used a code mailed to one of the experiment's recipients.
- Tracked link: the order's
utm_contentnames the experiment and arm, and the buyer's address is in that experiment. - In-email checkout: the buyer paid through a product block's own checkout in the email. A store order never matches this one.
- Email address (probable): the buyer's address belongs to a recipient who clicked through during the window before ordering. These orders are reported as probable.
The rules are picked before the lock, and only picked rules are checked. The first three are on by default. Email address (probable) is off until you pick it. A holdout, which gets no email, can only be matched by email address, so pick that rule when you have one. Only orders placed during the observation window count.
Revenue and promotional cost
Matched orders feed the results page's Revenue and promotions card, per arm and per currency:
- Revenue is the order's merchandise after discounts, without taxes and shipping, less refunds made in the window.
- Promotional cost is the orders' discounts, plus the average shipping cost you entered for each free-shipping order.
- Code redemption is the codes redeemed on a matched order, divided by the codes issued to the arm's recipients.
Revenue
- Arm A · 10% off$5,616
- Arm B · Free shipping$7,056
Promotional cost
- Arm A · 10% off$624
- Arm B · Free shipping$539
| Measure | Arm A · 10% off | Arm B · Free shipping |
|---|---|---|
| Revenue | $5,616 | $7,056 |
| Promotional cost | $624 | $539 |
Neither number is profit: the cost of the products sold isn't in either one. Orders in different currencies are shown apart and never added together.
Refunds come from Shopify's refund notifications and WooCommerce's order updates. A Shopify store connected before experiment rewards existed gets refund notifications only after you reconnect it. Revenue metrics covers how the results page reads these numbers.
Supported Offer Types
- Percentage Off: e.g., 15% or 20% sitewide, collection, or single-product discount.
- Fixed Amount Off: e.g., $10 or $25 off total cart value, or off one product.
- Free Shipping: for experiment arms only. See Different rewards per arm.
- Expiry Windows: Codes carry an auto-computed expiration date (e.g., 7 or 14 days from send time) so urgency is enforced on the merchant's store.
- Account Cooldowns: Built-in cooldown markers prevent over-couponing the same contact across multiple schedules or projects — one marker for the project-level offer, and a separate one per Product block, so discounting one product never blocks another's cooldown or the project-level offer's.
Monthly allowance
Each plan includes a number of store discount codes a month, shown under Settings → Plan & usage as Store discount codes. Every code MailInApp creates on your store for one contact counts once, whether it comes from a project's discount offer, a Product block's per-product discount, an experiment arm's reward or a game's store prize.
| Free | Starter | Lite | Pro | Business | Enterprise |
|---|---|---|---|---|---|
| 200 | 500 | 2,500 | 15,000 | 75,000 | Unlimited |
- A contact who gets a block's offer again during its cooldown receives the same code, counted once.
- MailInApp emails you when you've used 80% of the month's codes, and again when they're all used.
- Once the month's codes are used, emails keep going out on schedule with your store link in place of a code, and a game lands on one of its other prizes. A new allowance starts on the 1st of each month.
- Your whole product catalog syncs on every plan, so every product is ready to import.
Setup & API Integration
- Shopify: Requires connected store credentials with
write_discountsscope (one of the scopes your Shopify app is created with, see Connect your store). - WooCommerce: Requires connected store REST API consumer key and secret with read/write permissions.
A Product block's per-product discount additionally requires that block to have a real product imported via its Import from store picker (not a hand-typed external URL) — minting needs your store's own numeric product id to restrict the code to.

