Building a simple loyalty system in Shopify Flow without extra apps

By Philip Dematis · 11/20/2025 · 2 minutes read
building-a-simple-loyalty-system-in-shopify-flow-without-extra-apps
A practical way to build a simple loyalty system in Shopify using Flow. No external apps needed, just a few automated steps and some lightweight code inside the Run Code action.

Some stores only need a simple loyalty points system.

Shopify Flow can handle it without adding another app. By combining a flow, and a couple of metafields, you can create a basic setup that gives customers points and converts those points into discount codes when they reach a certain level.

Nothing here is complicated, but it does require the logic to be organized.

Below, a description of the basic version.

How the system works

You store customer points in a metafield.

Flow part 1 increases the points based on an order.

Flow part 2 checks if the points pass a threshold, and if they do, it creates a discount code and adjusts the points.

Flow part 1: Adding points

The flow runs when an order is paid. At that moment, you have everything needed to calculate new points.

Typical steps:

  • Trigger on order paid

  • Run code to read the current customer points from a customer metafield

  • Calculate the points earned from the new order

  • Add the new points to the previous balance

  • Update the customer points metafield with the result

Some stores use a formula like 1 point per dollar. Others use fixed numbers. Both work as long as the code reflects your structure.

Flow part 2: Generating discount codes

Here, you check if the total points are above the reward threshold.

If they are, you generate a discount code and subtract the threshold from the customer’s points so the balance stays correct.

  • Condition that checks if customer points exceed the threshold

  • Run code to subtract the threshold, get the updated point total, generate the discount code

  • Update the points metafield

  • Send an HTTP request to Shopify’s Discount API, or use an Admin mutation to create the actual code

  • Update a customer metafield to store the generated code

This creates a simple cycle: earn points, reach the threshold, get a code, and continue earning.

Where this method works well

This approach fits merchants who want a direct solution without depending on third-party apps. It’s also useful when you want full control over thresholds and how points accumulate. If your store has many returning customers, this type of setup can be enough.

A few practical use cases:

  • Stores that want a low-cost loyalty option

  • Brands that want to customize point calculations

  • Shops that want to display loyalty information directly on their theme

  • Teams that prefer building and maintaining their own automation logic

It’s limited compared to larger loyalty platforms, but for straightforward programs it does the job.

Showing the information on the storefront

Once the backend logic runs correctly, customers need a way to see their points and any active discount codes.

You can do this with:

  • Theme metafield outputs in Liquid

  • Dynamic sources in the theme editor

  • Small Custom Liquid blocks that read the metafield values

Common placements:

  • Account page showing the current point balance (you need an extension for this)

  • Cart page showing expected points earned from that order

  • Account page or popup showing the active reward code

Clear visibility helps customers understand the program without needing extra explanations.

FAQ

Do I need many metafields for this? Two is usually enough. One for points and one for the active discount code.

Does the discount code format matter? No. You can use a fully random code or add a prefix if you want consistency.

Can I send the discount code by email automatically? Yes, if your Flow setup includes an email action in your store.

Does this work on all Shopify plans? Yes. It relies on Flow, metafields, and the Discount API.

Conclusion

We demonstrated how a basic loyalty program is possible with Shopify Flow and a few metafields. It handles point tracking, discount creation, and works well for stores that need something straightforward without adding extra software.

Share icon
Facebook logoX logoLinkedIn logo

More articles

Contact us

Start a project. Or ask us anything.

200+projects completed
100+Shopify clients
10+Shopify Plus clients
Shopify partners logoShopify Plus logo