How it works

Follow these 10 simple steps to start syncing Shopify gift card balances to Klaviyo profiles daily

schedule icon

Schedule

App connector: Schedule • Time to complete: 1 minute
Why this matters: This trigger runs the gift card balance sync automatically once per day, ensuring your Klaviyo data stays current without overwhelming your systems with constant updates. Without automation, you'd need to manually track which customers have gift cards and what their balances are.

The schedule trigger runs daily at midnight (00:00 UTC). Each time it runs, it kicks off the entire workflow to retrieve all gift cards, calculate balances, and update Klaviyo profiles. You can adjust the frequency by modifying the schedule—for example, you could change it to weekly if daily seems excessive, or twice daily during high gift card redemption periods. The trigger automatically initiates at the configured time with no manual action required.

Get List of Gift Cards

App connector: Shopify • Time to complete: 0 minutes (Auto-configured)
Why this matters: This step retrieves all active gift cards from your Shopify store so the workflow knows which customers have gift card balances and how much value they hold. Without this comprehensive list, you'd have no way to calculate and sync total balances to Klaviyo.

The step fetches up to 8,000 gift cards from Shopify using the gift cards API endpoint. This includes the gift card ID, initial value, current balance, customer ID, and important dates like creation, expiration, and any disable dates. The limit is set to 8,000 to handle stores with large gift card programs—if you have more than 8,000 active gift cards, you may need to implement pagination or contact support to handle your volume.

Retrieve Shop

App connector: Shopify • Time to complete: 0 minutes (Auto-configured)
Why this matters: This step fetches your Shopify store domain, which is used to construct direct admin links to gift cards in the data table. These links help your team quickly access specific gift cards in Shopify admin without manually searching for them.

The step pulls your shop information, specifically your store domain (like "yourstore.myshopify.com"). This domain gets used in Step 5 to build URLs that link directly to each gift card's admin page in the format "https://admin.shopify.com/store/yourstore/gift_cards/{id}". This is auto-configured and runs in the background with no setup needed.

Loop

App connector: Loop • Time to complete: 0 minutes (Auto-configured)
Why this matters: With potentially thousands of gift cards to process, this loop ensures each one gets individually evaluated—retrieving its owner's details, storing it in the database, and calculating their total balance. Without this loop, the workflow could only handle one gift card at a time.

The loop iterates through all gift cards retrieved in Step 2, processing one gift card at a time through the remaining workflow steps. For example, if you have 500 active gift cards, the loop will run 500 times—once for each card—retrieving customer details, updating the data table, and syncing to Klaviyo for each unique customer. This loop structure allows the workflow to handle gift card programs of any size.

Retrieve Customer

App connector: Shopify • Time to complete: 0 minutes (Auto-configured)
Why this matters: Each gift card is assigned to a customer, and you need that customer's email address to match them in Klaviyo and sync their balance. This step fetches the complete customer record including email, name, and other details needed for syncing.

The step retrieves the full customer record using the customer ID from the gift card being processed in the loop. It pulls the customer's email (required to find them in Klaviyo), their first and last name (stored in the data table for reference), and any other customer properties. The API call automatically uses the customer ID from the current gift card to fetch the correct customer's details.

Update or Create Record

App connector: Data • Time to complete: 0 minutes (Auto-configured)
Why this matters: This step stores complete gift card details in a MESA data table, creating a centralized record of all your gift cards with customer information and direct admin links. This database enables the balance calculation in the next step and provides a searchable reference for your team.

The step creates or updates a record in the "Shopify Gift Cards" table using the gift card ID as the unique identifier. If the gift card already exists in the table (from a previous sync), it updates the record; if it's new, it creates a new record. Each record stores: Gift Card ID, Initial Value, Current Balance, Customer ID, Customer Email, Customer Name, Created/Updated/Expires/Disabled dates, and a direct admin URL to the gift card. This table acts as both a historical record and the data source for the balance calculation query in the next step.

Custom SQL Query

App connector: Data • Time to complete: 0 minutes (Auto-configured)
Why this matters: Customers can have multiple gift cards, and Klaviyo needs one total balance number to use in segmentation and personalization. This query adds up all gift card balances for the current customer, giving you their complete gift card value across all cards.

The step runs a SQL query against the "Shopify Gift Cards" table to calculate the sum of all gift card balances for the customer being processed. It filters by the customer's email and includes the condition WHERE "Disabled At" IS NOT NULL—though you should verify this logic matches your needs, as you may want to only count active cards (where Disabled At IS NULL). The query returns a single "Total Balance" value that represents all gift card value this customer holds.

Get Klaviyo Profile from Email

App connector: Klaviyo • Time to complete: 0 minutes (Auto-configured)
Why this matters: Before updating a customer's gift card balance in Klaviyo, you need to find their profile and verify it exists. This step searches Klaviyo by email address to locate the matching customer profile and retrieve its ID for updating.

The step queries Klaviyo's profiles API filtering by email address (using the customer email from Step 5) and limits results to 1 profile since emails should be unique. If a matching profile exists, it returns the profile ID needed to update their properties in Step 10. If no profile exists (customer hasn't been synced to Klaviyo yet), the query returns empty and the next filter step will stop the workflow for this customer.

Filter

App connector: Filter • Time to complete: 0 minutes (Auto-configured)
Why this matters: This filter prevents errors by only continuing to the profile update step when a matching Klaviyo profile was found. If a customer exists in Shopify but not in Klaviyo, attempting to update their profile would fail, so the workflow stops here for those customers.

The filter checks if the Klaviyo profile ID from Step 8 "is not empty." If a profile was found, the workflow continues to update it with the gift card balance; if no profile exists, the workflow stops here for this customer and moves to the next gift card in the loop. This is a hard-coded filter with no configuration needed—it automatically handles the workflow flow based on whether profiles exist.

Klaviyo logo icon

Update Profile

App connector: Klaviyo • Time to complete: 0 minutes (Auto-configured)
Why this matters: This is where the gift card balance actually gets synced to Klaviyo. The customer's total balance gets added as a custom property called "Gift Card Balance," making it available for email segmentation, flow triggers, and personalization tags in your campaigns.

The step updates the Klaviyo profile identified in Step 8, specifically adding or updating the custom property "Gift Card Balance" with the total balance calculated in Step 7. For example, if a customer has $85 across multiple gift cards, their Klaviyo profile gets a property Gift Card Balance: 85 that you can use in segments like "Gift Card Balance is greater than 20" or in email content with {{ person|lookup:'Gift Card Balance' }}. The update uses Klaviyo's v4 API and automatically handles creating the property if it doesn't exist.

Make it your own

Customize this workflow even further:

Segment by gift card value tiers
Use the synced "Gift Card Balance" property in Klaviyo to create segments like "High Value Gift Cards ($50+)," "Mid Value ($20-$49)," and "Low Value ($1-$19)," then send different reminder campaigns with urgency levels matched to the balance amount.
Trigger expiration reminders automatically
Since the workflow stores expiration dates in the data table, add a step that checks upcoming expirations and triggers a Klaviyo flow specifically for customers whose gift cards expire in the next 30 days, creating urgency to use their balance.
Track gift card redemption rates over time
Add steps to store historical balance snapshots in the data table with timestamps, then analyze month-over-month redemption patterns to understand how quickly customers use gift cards and optimize your reminder campaign timing.
Send monthly balance statements
Combine this workflow with a scheduled Klaviyo campaign that triggers monthly for anyone with a "Gift Card Balance" greater than 0, sending a personalized email that shows their current balance and suggests products they could purchase.

Frequently asked questions

Will this sync gift cards for customers who aren't in Klaviyo yet?
No, the workflow only updates existing Klaviyo profiles. If a Shopify customer with a gift card doesn't have a Klaviyo profile yet, Step 9's filter stops the workflow for that customer. You'll need to ensure customers are synced to Klaviyo (via another integration or workflow using Paths) before their gift card balances can be updated.
What happens if the SQL query in Step 7 needs adjustment?
The query currently includes WHERE "Disabled At" IS NOT NULL, which only counts disabled gift cards—you likely want IS NULL to count only active cards. You can edit this query directly in the workflow configuration to match your business logic, such as excluding expired cards or only counting cards above a certain balance threshold.
Can I sync this more frequently than daily if I have a high-volume gift card program?
Yes, you can change the schedule in Step 1 to run more frequently—every 12 hours, every 6 hours, or even hourly. However, be aware that processing thousands of gift cards multiple times per day increases your MESA automation usage and API calls to both Shopify and Klaviyo, so balance frequency with your actual business needs.
What is a template?
Templates are pre-made workflows by our team of experts. Instead of building a workflow from scratch, these have all the steps needed to complete the task.
Can I personalize a template?
Yes! Every step can be customized to meet your exact requirements. Additionally, you can even add more steps and make it more sophisticated.
Are templates free?
Yes! Our entire library containing hundreds of templates are free to use and customize to your exact needs.

Ready to start syncing Shopify gift card balances to Klaviyo profiles daily?

Join thousands who've automated their work and saved an average of 3.5 hours every week.

Start with this template — It's free
7-day free trial • 10 min setup • Cancel anytime