Generate Unique Discount Codes for New Shopify Customers on Specific Products

17 min setup
No coding required
Runs automatically

Drive repeat purchases by offering new customers a unique discount code for a specific product. This MESA workflow template automatically generates a 20% off discount code when a new customer is created in Shopify, sending it to them via SMS for use within 14 days. Customize the discount and target product to create urgency and turn first-time buyers into loyal customers, enhancing customer retention and driving future sales.

Shopify logo icon
Customer Created
Create Price Rule Discount Code
Customer Add Tag
Filter: Phone Number Check
sms icon
Send Message

You're in good company

"MESA has been a game changer for us. And, if you ever get stuck, their support team is always super helpful."

  • Ico star
  • Ico star
  • Ico star
  • Ico star
  • Ico star
PetFriendly

"It's like Zapier but exactly designed for Shopify. I have been able to complete all the workflows that I've needed."

  • Ico star
  • Ico star
  • Ico star
  • Ico star
  • Ico star
Zailys

"The MESA team has been amazing at helping us set up our automations. We would highly recommend this app!"

  • Ico star
  • Ico star
  • Ico star
  • Ico star
  • Ico star
Rothy's

How it works

9 steps to start generating unique product discount codes for new customers automatically

Shopify logo icon

Customer Created

App connector: Shopify • Time to complete: 1 minute
Why this matters: This trigger captures new customer account creations the instant they occur, enabling immediate discount code generation that can be sent via SMS while the customer is still engaged and likely to make their first purchase.

When a customer account is created in Shopify (through online checkout, in-store signup, admin creation, or API), this trigger activates the workflow and captures customer ID, email, phone number, name, and account creation timestamp. The workflow runs for every new customer account. No configuration is required—it's pre-connected to your Shopify store and monitors customer creation automatically.

New customer context: This includes customers who create accounts during checkout and customers who sign up via account pages. Guest checkouts that don't create accounts won't trigger this workflow.

Create Price Rule

App connector: Shopify • Time to complete: 8 minutes
Why this matters: Creates the Shopify price rule that defines discount parameters including value, eligible products, customer restrictions, and expiration, establishing the discount foundation that enables unique code generation.

This step creates a Shopify price rule with specific configuration.

Configuration: You must set several values during setup:

  1. Discount value: The discount amount (default -20 for 20% off)
  2. Value type: Either "percentage" or "fixed_amount"
  3. Expiration date: How long the code is valid (default 14 days)
  4. Entitled product ID: Which product the discount applies to

Price rule structure:

  1. title: "NEWCUSTOMER [customer_id] [timestamp]" (unique identifier)
  2. allocation_method: "across" (discount spreads across eligible items)
  3. value: Your configured discount amount
  4. value_type: Your configured type (percentage or fixed)
  5. target_type: "line_item" (discount applies to products)
  6. customer_selection: "prerequisite" (only specific customers can use)
  7. starts_at: Immediately (current timestamp)
  8. once_per_customer: "true" (each customer can use once)
  9. target_selection: "entitled" (specific products eligible)
  10. ends_at: Your configured expiration (default 14 days from now)
  11. entitled_product_ids: Your configured product ID
  12. prerequisite_customer_ids: The new customer's ID (restricts to this customer only)
  13. prerequisite_subtotal_range: Minimum $1 order (prevents abuse)

This creates a single-use, customer-specific, product-specific, time-limited discount.

Finding product ID: Go to Shopify admin > Products > select product > look at URL > copy numbers after /products/.

Retrieve Price Rule

App connector: Shopify • Time to complete: 0 minutes (Auto-configured)
Why this matters: Fetches the complete price rule record including the price rule ID needed for discount code creation, verifying successful creation before proceeding.

This step retrieves the price rule using the price rule ID from the creation response. It returns complete price rule data including ID, title, discount parameters, eligible products, customer restrictions, and expiration dates. The price rule ID is used in the next step.

Create Price Rule Discount Code

App connector: Shopify • Time to complete: 0 minutes (Auto-configured)
Why this matters: Generates the actual discount code that customers will enter at checkout, creating a unique, memorable code tied to the customer-specific price rule.

This step creates a discount code under the price rule. Code format:

  1. code: "NEWCUSTOMER[customer_id]" (like "NEWCUSTOMER12345678")

The code is automatically associated with the price rule, inheriting all discount parameters, restrictions, and expiration settings. The unique customer ID ensures each customer gets a different code for tracking and preventing sharing.

Code customization: You can modify the code format to match your brand (like "WELCOME[customer_id]" or use random strings), but ensure it remains unique per customer.

Customer Add Tag

App connector: Shopify • Time to complete: 0 minutes (Auto-configured)
Why this matters: Tags the customer with their discount code in Shopify admin, enabling easy lookup of which codes belong to which customers and tracking which customers received welcome offers.

This step adds the discount code as a customer tag. The tag format matches the code (like "NEWCUSTOMER12345678"), creating a permanent record in the customer profile. This enables:

  1. Quick customer service lookups ("What was this customer's welcome code?")
  2. Segment creation for customers who received welcome offers
  3. Reporting on welcome offer redemption rates
  4. Bulk actions on customers with welcome codes

Retrieve Product

App connector: Shopify • Time to complete: 0 minutes (Auto-configured)
Why this matters: Fetches complete product information including product title needed for personalizing the SMS message with the specific product name customers can use their discount on.

This step retrieves the product record using the entitled product ID from the price rule. It returns product data including title, description, images, and pricing. The product title is used in the SMS message to clearly communicate which product the discount applies to.

Retrieve Shop

App connector: Shopify • Time to complete: 0 minutes (Auto-configured)
Why this matters: Fetches your store name for personalizing the SMS message with your brand name, making the text message feel authentic and branded rather than generic.

This step retrieves shop information from Shopify, specifically the shop name. This name appears in the SMS message like "Thank you for shopping with [Your Store Name]", creating a branded customer experience.

Filter: Phone Number Check

App connector: Filter • Time to complete: 0 minutes (Auto-configured)
Why this matters: Verifies the customer has a phone number before attempting SMS sending, preventing workflow failures and ensuring SMS only goes to customers who can receive texts.

This filter checks if the customer's phone number field is not empty. If true (phone exists), the workflow proceeds to send SMS. If false (no phone), the workflow stops here. The customer still received their discount code and tag, they just don't get the SMS notification.

Alternative notification: Customers without phone numbers could receive the discount via email instead by adding an email step in a separate path.

sms icon

Send Message

App connector: SMS • Time to complete: 2 minutes
Why this matters: Delivers immediate notification of the welcome discount directly to the customer's phone, providing a convenient, high-visibility channel that drives immediate engagement and first purchases.

This step sends an SMS to the customer's phone number. Configuration: You can customize the message during setup. The default message is:

"Thank you for shopping with [Store Name].

Take 20% off on the [Product Title].

Use online code: [Discount Code]"

SMS best practices:

  1. Keep message under 160 characters if possible (avoids multi-part SMS)
  2. Clearly state discount value and product
  3. Include the code prominently
  4. Consider adding a link to the product page
  5. Ensure discount details match what you configured in price rule

SMS costs: MESA SMS has per-message costs. Consider your customer volume when deciding whether to use SMS vs email.

Ready to set this up? It only takes 17 minutes.

Our support team will even help you personalize this workflow for free.

Get started →

Make it your own!

Customize this workflow even further:

Add email notification
Insert an email step (either replacing or supplementing SMS) that sends a welcome email with the discount code, product image, and call-to-action button, providing a richer notification experience.
Create tiered discounts
Add conditional logic that checks customer tags, order history, or other factors and varies discount amounts for different customer segments, creating VIP welcome offers.
Apply to product collections
Modify the price rule to use entitled_collection_ids instead of entitled_product_ids, allowing the discount to work on any product in a collection like "Welcome Collection" or "First Purchase Items".
Send reminder SMS
Create a companion workflow triggered by a schedule that checks for customers with welcome code tags who haven't placed orders and sends reminder texts before codes expire.

Common questions

Can customers share their discount codes?

What happens if a customer creates an account but doesn't provide a phone number?

Can I change which product the discount applies to without recreating the workflow?

Ready to start generating unique product discount codes for new customers automatically?

7-day free trial • 17 min setup • Cancel anytime

Need help? Our automation experts will help you personalize this workflow for free. Contact support