I’m working on an automation that should send reminder emails to customers who haven’t used their personal discount codes after a certain time.
Here’s the situation:
Each customer who makes a purchase over €200 receives a unique discount code (e.g. €10 off).
The code is created automatically in Shopify and linked to the customer (under “Specific customers”).
The code has an expiry date (usually 3 months).
I would like to build a Shopify Flow that:
Triggers when a discount code is created,
Waits 30 days,
Checks if the code has been used,
Sends a reminder email (via Shopify Email or Klaviyo) to the associated customer if not used.
The issue is that when using the Flow trigger “Discount code created”, the customer object is not available — I can’t access the customer’s email, name, or ID, so I can’t send the reminder email or connect it to Klaviyo.
I’ve also tried using Flow’s “Track an Event” to push the discount creation into Klaviyo, but ran into the same limitation (no access to customer data in the Flow context).
What I need help with:
Is there any way (API, Liquid variable, workaround, or app) to retrieve the customer information linked to a discount code when it’s created?
Could this be achieved with a custom Flow action, webhook, or a Mechanic script?
Any technical guidance, examples, or workarounds would be greatly appreciated.
You can retrieve a list of client emails using a GraphQL query. For example, a query that fetches a list of customer emails from a discount for free shipping looks like this:
You can execute a GraphQL query in Shopify Flow either using the built-in Send HTTP Request action or the Execute GraphQL request action provided by the Flow Companion app.
You can then parse the result in a Run Code action.
If you decide to use the Execute GraphQL request action from the Flow Companion app, you can contact the app’s support, and they will help you set up workflows of any complexity.
I also found that this data can be retrieved using the Get discount data action. In this case, no coding is required, but you do need to compose a query to filter the result. The simplest option, in my opinion, is to use a query like
{% for codes_item in discount.codeDiscount.DiscountCodeBasic.codes %}
code:"{{codes_item.code}}"
{% endfor %}
since, as far as I understood your task, you use one code per discount.