Shopify Flow: advanced query filter for Get Customer Data action

Topic summary

A user is attempting to filter customers in Shopify Flow’s Get Customer Data action using an advanced query with a logical AND operator. They want to find customers with a specific tag (EdTest) who live in the UK, but the query behaves as if using OR instead of AND.

Key Issue:

  • Query syntax like default.defaultAddress.country:NotACountry is invalid because query filters don’t support dot notation (except for metafields)
  • The invalid portion gets ignored by the API, causing unexpected results

Solution Provided:

  • Available query filters are limited and documented in the Shopify Admin GraphQL API reference
  • The “country” filter exists but is deprecated in favor of customer segments
  • Filtering by city/town is not possible through queries

Recommended Approach:

  • Use customer segments instead for more complex filtering requirements
  • Leverage Segment Joined/Left triggers in Flow workflows
  • Reference Shopify’s customer segmentation documentation for implementation guidance

The discussion remains open for the user to explore the segments approach.

Summarized with AI on November 1. AI used: claude-sonnet-4-5-20250929.

I am trying to combine two conditions with a logical AND in an advanced query in the Get customer data action in my workflow. My customers have the tag EdTest and live in the UK; so I would expect the following expression to evaluate to FALSE:

tag:EdTest AND default.defaultAddress.country:NotACountry

However, this evaluates to TRUE for all customers with the EdTest tag (as if the AND were in fact an OR). I’ve also tried a variation of the query syntax without the leading “default.”:

tag:EdTest AND defaultAddress.country:NotACountry

but the result is the same. (See images below.)

How can I filter my customers based on a property of their address?

Query filters don’t allow you to use “.” to specify the filter name, with the exception of metafields, so this is invalid and thus ignored by the API:

default.defaultAddress.country:NotACountry

Also, I’m not sure where you got “NotACountry” but that is unlikely to work in any situation.

The list of available query filters are here:

https://shopify.dev/docs/api/admin-graphql/2024-04/queries/customers#argument-query

There is a “country” filter. I’m not sure if it filters by default address or some other address. I’ll note that the filter is also deprecated in favor of segments. So you may want to instead create a segment and use Segment Joined/Left triggers in conjunction with the segment.

1 Like

Thanks Paul - that’s helpful. How can I filter my customers according to the town or city in which they live (as specified in their default address)? Should I use segments instead? I’ve never heard of those, so if you could point me to some examples, that would be very helpful.

You can’t query by city or town. So if you want that, then segments is probably better.

Start here

https://help.shopify.com/en/manual/customers/customer-segmentation/create-customer-segments

1 Like