ETLMCPData Conveyance Works
Log in Start free
Guides

Shopify order name, number and ID: which to join on

Join Shopify orders on the global ID plus the store, not on the '#1001' name or the order number, which repeat across stores and are not guaranteed unique.

Coming This connector is coming.

To match a Shopify order to a row in your CRM, a conversion export or another store's data, join on the order's id (its global ID) and keep the store's domain next to it. Do not join on the name, such as #1001, or on the order number. Shopify documents the name as the label shown in the admin and on the order status page, and says it is not unique across stores. It documents the number as neither guaranteed sequential nor guaranteed unique, even inside one store.

The identifiers on an order

Shopify's Order object in the GraphQL Admin API carries several values that look like an order ID.

Field What it is Safe as a join key
id The global ID: a string naming Shopify, the object type Order and a numeric ID Yes, with the store
legacyResourceId The same order's numeric ID in the REST Admin API Yes, with the store
name The label staff and customers see, such as #1001, EN1001 or 1001-A No
number The integer the name is built from No
confirmationNumber A customer-facing code, often shown in place of the name No

The name is built from the number plus the prefix and suffix configured for the store. So a join that strips # and compares digits fails as soon as a store uses a prefix like EN or a suffix like -A. It fails again when you add a second store, because Shopify says the name is not unique across stores: two shops can both have a #1001.

Shopify does not promise that numbers run 1, 2, 3 without gaps, nor that a number is unique across stores or within one store. So a gap in the sequence does not by itself prove an order is missing, and a repeated number does not by itself prove a duplicate.

The orders query's documentation describes the confirmation number as a random code and says it may not be unique.

Why the global ID needs the store

Shopify's page on global IDs describes each one as a URI made of a fixed Shopify prefix, the object type and an ID, and the Order object calls its id globally unique. Still, the string contains no store, and the global IDs page does not discuss more than one store. Store the shop's myshopify.com domain in the same row and join on the pair. If one side of your join holds REST IDs, map them through legacyResourceId or the REST side's admin_graphql_api_id, which Shopify documents for exactly this mapping, rather than parsing the string yourself.

Where an order came from: sourceName and channels

sourceName says where the order was placed. Shopify's examples are web, mobile_app and pos. For point-of-sale and third-party orders, sourceIdentifier holds the originating system's own order ID, which is what to match against a POS or marketplace export.

The orders query can filter on these. Shopify describes source_name as telling web orders apart from point-of-sale sales and other origins, and gives source_name:web and source_name:shopify_draft_order as examples. There is also a sales_channel filter for the channel the order was made through, a source_identifier filter and a name filter.

Shopify's search syntax page contradicts itself about an invalid filter field. Its text says the query is then ignored and every result comes back; its own debugging example, a products query with an invalid field, returns no products at all. So a misspelled field can silently give you the whole store or nothing. Shopify reports search warnings under extensions in the response, and the Shopify-Search-Query-Debug=1 header makes it return that section for every query. Treat any warning there as a failed query.

What etlmcp does with order identifiers

When the Shopify connector is available, etlmcp will not export order-level rows, so you will not be able to join single orders from its tables. For each local day in the store's time zone, it reads that day's orders, counts the ones that are neither test orders nor cancelled, and writes one row for each date that has at least one such order. The row's account_id is the store's myshopify.com domain, and its campaign, ad group and ad IDs are empty. Inside a day it keys orders by their global id, so an order that paging returns twice counts once. Its query asks for no name, number or sourceName and filters only on the creation time, so each daily row adds up orders from every channel together.

It also sends the debug header on every request and fails the fetch on any search warning, with the error shopify did not apply the order date filter. It then checks that each order returned falls inside the day it asked for, so an ignored date filter cannot turn into a day holding the whole store. Each routine sync pulls the last 58 days again. See the Shopify connector for its columns.

Related

Sources

  1. Order - GraphQL Admin — shopify.dev, checked
  2. orders - GraphQL Admin — shopify.dev, checked
  3. Global IDs in Shopify APIs — shopify.dev, checked
  4. Search query syntax — shopify.dev, checked