Dynamic code for discount in email

I need advice on email campaigns in shopify. The newsletter is set up in app flow. How can I add the same code to the code for discount reminder email that was sent in the first email? Provided that the code is dynamic and a unique code is generated for each recipient. I will be grateful for your help)

3 Likes

Hi @Aurimka ,

It sounds like you’re using Shopify’s Shopify Flow app to automate email campaigns, and you want to ensure that the same unique discount code from the first email is included in the discount reminder email. Since Shopify Flow doesn’t store previous discount codes natively, here’s a way to achieve this:

Solution: Store and Reuse the Discount Code

  • Use Shopify Flow to Generate Unique Discount Codes: In your first email, you likely used Shopify Flow to create a unique discount code per recipient. Make sure you store this code somewhere that you can access later.

Store the Discount Code in Customer Metafields

Since each recipient gets a unique code, you can save it to a metafield on the customer profile:

Use a Shopify Flow action to add the discount code to the customer’s metafields.

Example metafield: customer.metafields.custom.discount_code

Retrieve the Discount Code in the Reminder Email

When setting up the discount reminder email, retrieve the stored code using Liquid:

Your exclusive discount code: {{ customer.metafields.custom.discount_code }}

This ensures that each customer gets the exact same code in both emails.

Hope these steps will help you, let me know if you need any help.

Regards,

1 Like

Thank you for your response. I’ve already done this, but I got to the point of updating the metafield and I don’t know what exactly I need to specify in the Value field. Since the code is dynamic, should the Value field contain a variable or a static value of the code name?

To manage the customer text metafield, you have to create a program to write the dynamic code into the created metafield, and you can manage it from there. if you have any queries, feel free to ask us.

What should this program look like and where can I create it?

@Aurimka , wanted to check in here and see if you were able to work out a solution for this one? If not I think this can be done through flows (but there’s a limit of upto 1000 customers in that)

But before I dive deeper - wanted to ask, what’s the email platform you use to build your campaigns. You mentioned “app flow” so I’m assuming Klaviyo. But I wanted to be sure.

Thanks,

@Aurimka , Since quite some time has passed since you raised this thread, I’m assuming you’ve already reached at a solution :slightly_smiling_face:

If so - can you please share the same and close this thread out so that others who stumble here might also find value.

Best,