Send survey answers to Klaviyo with Shopify Flow

Shopify Flow can send a customer's answers to Klaviyo as an event on their profile. Zenith starts the workflow, Flow looks up the order to find the customer's email, and Klaviyo's Track an Event action sends the event to your Klaviyo account. Send one event per finished survey with every answer in it, or one event for a single question.

Before you start

  • A Flow workflow that starts on Zenith's trigger. If you have not made one yet, follow steps 1 to 3 of setting up Shopify Flow for Zenith, then come back here for step 4.
  • Klaviyo's Shopify app, installed and connected to your Klaviyo account.
  • Your Klaviyo public API key, from Settings, API keys in Klaviyo. A private key is not needed.

One event per order

Choose Survey completed as the trigger in step 3. Each finished survey sends one event carrying every answer. A customer who stops partway sends nothing.

  1. Look up the order

    Click +, choose Action and search for Get order data. Set Maximum number of orders to 1. Under Shopify API search query string, choose Advanced, and in Edit query enter id:{{orderId}}. This finds the order the survey was answered on, which is where the customer's email comes from. No condition is needed first: Survey completed runs once per order.

  2. Loop over the order

    Click +, choose Action and add For each loop (iterate). Under Items, choose Get order data. For each has two branches, Repeat for each item and After last item. The next step goes under Repeat for each item, not After last item.

  3. Send the event to Klaviyo

    Under Repeat for each item, click +, choose Action and search for Track an Event, the one from Klaviyo. Fill it in: Klaviyo Public API Key is your public key, Event Name is a name for the event (for example, Zenith: Survey completed), Customer Email Address is {{getOrderDataForeachitem.email}}, and Event Properties is the block below.

  4. Turn it on

    To give it a name, click More actions, then Rename. Then click Turn on workflow, and Turn on to confirm.

Event Properties, every answer at once:

{{answersJson}}

Paste it alone, with no | json after it: it is already JSON. Klaviyo shows each answer as a separate property on the event, named after its question, alongside the fixed fields Answers JSON starts with, among them order_id, nps_score, nps_band, csat_score, ces_score and the question counts. The variables tables list them all.

  • Segment on nps_band, not the score. Scores arrive as text, and as n/a when your survey has no such question, so they do not compare as numbers. nps_band is always one of detractor, passive or promoter, or n/a without an NPS rating.
  • Rewording a question changes its property. Answers JSON uses each question's text as its key, so after you reword a question its answers arrive under the new wording, and segments built on the old wording stop matching.

One event per answer

Choose Survey response received as the trigger in step 3. This version sends the answer to one question, How did you hear about us? in this example, as its own event, and the same steps work for any other question.

Add the Klaviyo steps

  1. Keep one question

    Click + under the trigger and choose Condition. Set it to check that question is equal to the question you want to send to Klaviyo, typed exactly as your survey shows it (for example, How did you hear about us?). Add every step below on the path where the condition is true. Zenith starts a workflow for each question a customer answers or skips, so this is what limits it to one event per order. To send other questions too, such as your NPS question, repeat this workflow for each one, with its own event name.

  2. Look up the order

    Click +, choose Action and search for Get order data. Set Maximum number of orders to 1. Under Shopify API search query string, choose Advanced, and in Edit query enter id:{{orderId}}. This finds the order the survey was answered on, which is where the customer's email comes from.

  3. Loop over the order

    Click +, choose Action and add For each loop (iterate). Under Items, choose Get order data. Get order data always hands back a list, even of one order, and the loop is how the next step reads it.

  4. Send the event to Klaviyo

    Under Repeat for each item, click +, choose Action and search for Track an Event, the one from Klaviyo. Fill it in: Klaviyo Public API Key is your public key, Event Name is a name for the event (for example, Zenith: How did you hear about us), Customer Email Address is {{getOrderDataForeachitem.email}}, and Event Properties and Customer Properties are the two blocks below.

  5. Turn it on

    To give it a name, click More actions, then Rename. Then click Turn on workflow, and Turn on to confirm.

The properties to paste

Event Properties, the answer, any comment and the order, on the event:

{"answer": {{answer | json}}, "comment": {{comment | json}}, "order_id": {{orderId | json}}}

Customer Properties, the answer saved on the customer's profile:

{"heard_about_us": {{answer | json}}}

Paste each variable ending in | json as it is, without quotes around it. | json adds the quotes itself, and it keeps a quote mark in a customer's answer from breaking the properties. Every other field is in the variables tables, and any of them can go in the same way.

What to do with it in Klaviyo

  • Segment by answer. Create a segment on what someone has done, choose your event at least once, then click the filter icon on that row to add a property filter: on the per-order event, the property named after your question; on the per-answer event, answer equals, for example, Instagram. The filter is on that icon, not in the count field.
  • See it on the profile. The per-answer Customer Properties block saves the answer as heard_about_us on the customer's Klaviyo profile, beside the event.
  • Start a flow from the event. A Klaviyo flow can be triggered by the event. For a follow-up after a low NPS score, trigger the flow on the per-order event and filter it on nps_band equals detractor.

What to know

  • Without the condition, one event per question. The per-answer workflow runs once for every question a customer answers or skips, so a customer who answers three questions sends three events.
  • An empty comment arrives as n/a. On the per-answer event, an answer without a comment sends "comment": "n/a".
  • Events can take a minute or two to appear on the profile in Klaviyo.
  • Zenith cannot see your workflows. If events stop arriving, check the workflow in Flow itself.

Privacy

Zenith never receives or sends the customer's email. Your own workflow looks it up inside Shopify and sends it, with the answers, to your Klaviyo account. Your privacy policy should cover sending survey answers to Klaviyo.

Install Zenith from the Shopify App Store