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:
- Store their email (either in Shopify’s customer list, a Google Sheet, or an email marketing tool like Klaviyo).
- Assign a unique discount code from your list of 5000 pre-generated codes.
- 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.