We’re trying to set up a Shopify Flow which identifies failed deliveries and passes on the courier’s unique tracking number (along with the customer email and order name) to Klaviyo as Event Properties (see also Klaviyo’s docs).
The trigger of the Flow is a Scheduled Run combined with a Get Order Data action after which we run a ‘For Each’ loop on all the orders to send them to Klaviyo.
So far we got the customer email and orderNumber working by passing this to Klaviyo as follows:
As for the tracking number, we are able to produce this via the following loop:
{% for fulfillmentOrders_item in getOrderDataForeachitem.fulfillmentOrders %}
{% for fulfillments_item in fulfillmentOrders_item.fulfillments %}
{% for trackingInfo_item in fulfillments_item.trackingInfo %}
{{trackingInfo_item.number}}
{% endfor %}
{% endfor %}
{% endfor %}
However, this in theory produces a list of tracking numbers whereas we only need a single tracking code value as we’ll never have more than one tracking number assigned to an order. How can we condense the above loop in a single line statement that can be passed on as an Event Property to Klaviyo?
If you use ParcelPanel to connect Klaviyo via API, you can accomplish more than passing the tracking number, but also updating your customers on the latest shipment status. For example, after the shipment status is changed to “Delivered,” it will be the best time to send a review request email.
Your loop seems correct (check if there’s your needed data sent), once you have this create a new “then” event in Flow. That is HTTP Request to Klaviyo API to send only the current transaction. I’ll follow the post.