Tracking orders using Shopify Flow

The Customizer Shopify app can automatically detect new and updated orders and initiate the corresponding integrations. This functionality relies on Shopify’s order webhook subscription feature, which delivers a complete order payload upon order creation or update.

These payloads include user information such as customer names, email addresses, and shipping addresses. As a result, some merchants may have concerns about transmitting personally identifiable information (PII) to third-party systems through these hooks.

The standard Customizer Shopify app utilizes the order tracking API as described in the Tracking orders documentation. While the app provides a convenient and ready-to-use method for enabling order tracking and recipe association, equivalent workflows can also be implemented using the Shopify Flow automation builder.

Caveats

Shopify Flow can be triggered only when an order is created or cancelled. When an order is edited in Shopify Admin—e.g., changing quantities or removing line items—the automation workflow will not be triggered, and some order → recipe information may become outdated. Please ensure the appropriate teams are notified if order changes are made.

Creating a Flow automation

  • Navigate to Shopify admin and click into Flow app

  • Create a new workflow

  • Select a desired trigger — Order Created or Order Cancelled

CleanShot 2025-04-20 at 15.20.48@2x-20250420-192055.png
  • Add a new Action

CleanShot 2025-04-20 at 15.21.32@2x-20250420-192140.png
  • And select Sent HTTP Request under Flow category

CleanShot 2025-04-20 at 15.22.07@2x-20250420-192220.png
  • Edit the action settings as follows

  • Change the HTTP Method to POST

CleanShot 2025-04-20 at 15.23.07@2x-20250420-192311.png
  • Click Add Variable next to the URL field

  • Select Shop

CleanShot 2025-04-20 at 15.26.01@2x-20250420-192611.png
  • Search or scroll down to find and select metafield variable

CleanShot 2025-04-20 at 15.26.33@2x-20250420-192640.png
  • Select Use unstructured

CleanShot 2025-04-20 at 15.27.22@2x-20250420-192726.png
  • Paste the following text as Namespace and key

drive_commerce_settings.primaryRuntimeOrdersKey
  • Leave other settings as-is and select Add

CleanShot 2025-04-20 at 15.28.32@2x-20250420-192841.png
  • On the next screen select value

CleanShot 2025-04-20 at 15.29.16@2x-20250420-192925.png
  • The URL field should change to {{shop.primaryruntimeorderskey.value}}

  • Add Headers setting: Content-Type with value application/json

CleanShot 2025-04-21 at 20.19.18@2x-20250422-001921.png
  • Paste the following URL into the URL field:

https://api.customizer.drivecommerce.com/api/v2/recipe/order?apikey={{shop.primaryruntimeorderskey.value}}
  • Paste the following code into the Body field:

{% capture json_body %}
[
  {% assign first_item = true %}
  {% for item in order.lineItems %}
    {% if forloop.first != true and first_item != true %},{% endif %}
    {% assign has_recipe_id = false %}
    {% assign is_primary = false %}
    {% assign recipe_id_value = "" %}
    
    {% for attribute in item.customAttributes %}
      {% if attribute.key == '_Drive Recipe ID' %}
        {% assign has_recipe_id = true %}
        {% assign recipe_id_value = attribute.value %}
      {% endif %}
      {% if attribute.key == '_Drive Type' and attribute.value == 'Primary' %}
        {% assign is_primary = true %}
      {% endif %}
    {% endfor %}
    
    {% if has_recipe_id == true and is_primary == true %}
      {% assign order_id_str = order.id | remove: 'gid://shopify/Order/' %}
      {% assign item_id_str = item.id | remove: 'gid://shopify/LineItem/' %}
      {% assign order_number_clean = order.name | remove_first: '#' %}
      {
        "recipeId": {{ recipe_id_value | json }},
        "orderNumber": {{ order_number_clean | json }},
        "orderId": {{ order_id_str | json }},
        "itemId": {{ item_id_str | json }},
        "itemQuantity": {{ item.quantity }}
      }
      {% assign first_item = false %}
    {% endif %}
  {% endfor %}
]
{% endcapture %}
{{ json_body }}
  • Double-check settings:

    • POST http method

    • URL that points to Customizer and uses the variable

    • Body with the template code

CleanShot 2025-04-20 at 15.32.30@2x-20250420-193242.png
  • Save and activate the workflow

Creating additional automations

The automation flow created on the previous set is triggered when an order is created. It is recommended to create additional automation to trigger when the order is cancelled.

Follow the previously described steps to create a flow; however, change the HTTP method to DELETE:

CleanShot 2025-04-20 at 15.35.01@2x-20250420-193504.png