---
title: Trigger Shopify Flow when a customer metafield changes
description: >-
  Start a Shopify Flow workflow when a customer metafield changes. Track it in
  Workflow Trigger Extensions and get the old and the new value.
source_url:
  html: >-
    https://docs.workflow-trigger-extensions.app/customer-metafield-trigger
  md: >-
    https://docs.workflow-trigger-extensions.app/customer-metafield-trigger.md
---

# Customer metafield trigger

A fashion store lets customers save their size in the customer metafield **Clothing size** (`custom.clothing_size`). When a customer changes it, the store wants to follow up, for example with products in the new size.

This page shows how to start a Shopify Flow workflow whenever a metafield of a customer changes, with **Workflow Trigger Extensions**. The steps are the same for every metafield of this resource type; the example uses **Clothing size** (`custom.clothing_size`).

## What you need

- **A metafield definition.** Create it in your Shopify admin under **Settings > Metafields and metaobjects > Customers**. A metafield without a definition cannot be tracked.
- **The permission Customer Data Access.** Grant it on the app's **Permissions** page, see [Permissions and data access](https://docs.workflow-trigger-extensions.app/permissions-and-data-access.md).

## 1. Track the metafield

1. Open **Metafield Triggers** in the app and click **Add trigger**.
2. Choose the resource type **Customer**.
3. Tick the metafield, here **Clothing size**. You can tick several at once or use **Select all**.
4. Click **Add trigger**.

To track every metafield of this resource type, including the ones you create later, choose **All metafields** instead of ticking single ones, then click **Track all metafields**.

![The Add Metafield Trigger dialog with resource type Customer and the metafield Clothing size, custom.clothing_size, ticked](https://cdn-dev.eu.codecreationlabs.cloud/crm-tool/uploads/SjJ78gKLnLlocopCui3Cs62dJbGZ7F1n/95807be79e159aa9.png)
*Resource type Customer, the metafield ticked. All metafields tracks every metafield of the type instead.*

The new trigger shows **Initializing** while the app reads the current value of the metafield on your existing customers, then **Active**. That first reading is why the very first change already arrives with the right previous value.

If the metafield is missing from the list, click **Refresh Metafields** on the Metafield Triggers page: the app remembers the list of definitions for an hour.

## 2. What the workflow receives

Every change starts the trigger **Metafield Update** in Shopify Flow with these values:

| Variable | Value |
| --- | --- |
| `resourceType` | `CUSTOMER` |
| `resourceId` | The ID of the customer, for example `gid://shopify/Customer/1234567890` |
| `metafieldKey` | Namespace and key, here `custom.clothing_size` |
| `metafield.value` | The new value |
| `metafield.previousValue` | The value before the change, empty when the metafield was set for the first time |
| `metafield.type` | The type of the metafield, for example `single_line_text_field` |

**Customer Metafield Update** is a second trigger for the same change. It starts in addition to Metafield Update and carries the customer as a native Flow reference, so Shopify's own customer actions work on it without a lookup step. Both share one event, so using both does not count twice. Switch it on from the app's **Triggers** page, or turn on a workflow that uses it.

## 3. Build the workflow

1. In Shopify Flow, create a workflow and choose the trigger **Metafield Update** of **Workflow Trigger Extensions**.
2. Add a **Condition**: `resourceType` is equal to `CUSTOMER`. Metafield Update starts for every resource type you track, so the condition keeps this workflow to customers. When you track several metafields of the type, add `metafieldKey` is equal to `custom.clothing_size` as a second criterion.
3. Add the action you need. The example sends an internal email with the old and the new value.

![The example workflow in Shopify Flow: Metafield Update, a condition on resource type CUSTOMER and Send internal email](https://cdn-dev.eu.codecreationlabs.cloud/crm-tool/uploads/SjJ78gKLnLlocopCui3Cs62dJbGZ7F1n/7f31f4e32ca64b10.png)
*The example workflow: the trigger, the condition on the resource type and one action.*

### Start from the example

1. Download the `.flow` file attached at the bottom of this page.
2. In your Shopify admin open **Flow**, click **Import** and choose the file.
3. Open the **Send internal email** step and enter the recipient. The file holds no address on purpose.
4. Turn the workflow on.

## Make it yours

- Tag the customer: add the action **Add customer tags** and put `{{resourceId}}` in its customer field.
- Use **Customer Metafield Update** when the workflow should read more of the customer, such as the email address.
- Add a condition on `metafield.value` to react to one size only.

## How fast it reacts

Shopify notifies the app when a customer is saved, so the workflow usually starts within a few seconds.

## Good to know

- A customer that is created with the metafield already filled, for example by a sign-up form, starts the workflow once, with an empty previous value.

> [!NOTE]
> **Counts toward your plan**
> Every change of a tracked metafield counts as one event of your plan, see [Plans and usage](https://docs.workflow-trigger-extensions.app/plans-and-usage.md).

## More

- [Metafield triggers](https://docs.workflow-trigger-extensions.app/metafield-triggers.md): how metafield triggers work, for every resource type.
- [Trigger Shopify Flow on customer metafield updates](https://docs.workflow-trigger-extensions.app/customer-metafield-update-guide.md): a worked example with a video.
- [Event history and troubleshooting](https://docs.workflow-trigger-extensions.app/event-history-and-troubleshooting.md): see every event the app sent, with the old and the new value.
