How to show pre-generated coupons cosdes.

Topic summary

A merchant has 5,000 pre-generated discount coupons for their Amazon store and wants to distribute them through their Shopify site. The goal is to collect customer names and emails, then provide each visitor with a unique single-use coupon code—either displayed on-page or sent via email.

Proposed Solution:

  • Step 1: Create a form using Shopify Forms, Privy, Klaviyo, or custom HTML/Liquid to capture name and email
  • Step 2: Store collected emails and automate code assignment using JavaScript to randomly select and display a code from the pre-generated list, or integrate with email marketing tools for automated delivery
  • Step 3: Ensure coupon codes are properly configured in Amazon (or Shopify if applicable) for checkout redemption

A code snippet example was provided showing how to display a random coupon on-page after form submission. The discussion remains open for further implementation questions.

Summarized with AI on November 1. AI used: claude-sonnet-4-5-20250929.

I have generated 5000 discount coupons for my Amazon store. Now I aim to streamline the process for distributing these coupons. My objective is to prompt customers landing on my Shopify site to provide their name and email. Upon submission, I would like to deliver a single-use coupon code either via email or by displaying it on the website. This code will grant them the desired discount when used at checkout on my store.

Could you please advise on how to implement this functionality? Your assistance would be greatly appreciated.

Hi @yawarabbas

I totally get what you’re trying to achieve—automating the distribution of your Amazon discount codes while collecting customer emails through your Shopify site. That’s a great way to build your email list and drive sales at the same time.

Here’s how you can do it:

Step 1: Set Up a Form to Collect Name & Email

You’ll need a form on your Shopify site where users enter their name and email to receive a unique discount code. You can use an app like Shopify Forms, Privy, or Klaviyo to do this. If you prefer custom coding, you can embed an HTML form and link it to a backend system.

A simple Shopify Liquid + HTML form example:

Get Your Discount Code

Step 2: Store Emails & Automate Code Distribution

Once a user submits their info, you need to:

  1. Store their email (either in Shopify’s customer list, a Google Sheet, or an email marketing tool like Klaviyo).
  2. Assign a unique discount code from your list of 5000 pre-generated codes.
  3. Deliver the code via email or display it on the page.

If using Klaviyo or Omnisend, you can create an automation:

  • Trigger: A user submits the form.
  • Action: Automatically send them an email with a unique code.

For direct page display, use Javascript:

document.getElementById(“discountForm”).addEventListener(“submit”, function(event){

event.preventDefault();

// Fetch a unique coupon code (assuming stored in an array)

let couponCodes = [“CODE123”, “CODE456”, “CODE789”]; // Replace with your real codes

let randomCode = couponCodes[Math.floor(Math.random() * couponCodes.length)];

document.getElementById(“couponDisplay”).innerText = "Your discount code: " + randomCode;

});

This will instantly show the discount code on the page after submission.

Step 3: Apply the Coupon at Checkout

If you’re sending customers to Amazon, make sure your coupon codes are set up there. If you’re using Shopify discounts instead, pre-generate the codes under Discounts > Create Discount and link them.

That should do it! With this setup, you can automate code distribution and grow your email list effortlessly. If you need extra help, just let me know asap. Thanks
Daisy.