Hi, I am trying to export customer info from a customer segment with graphql like the export customers on the segment admin page, but I can’t find any customer id or customer object from customersegmentmembers customerSegmentMembers - GraphQL Admin
Why customer id or customer object is missing from customersegmentmembers? The id it returns is gid://shopify/CustomerSegmentMember/…, which is useless for my purpose.
In my testing here, the integer following CustomerSegmentMember is the same as the customer ID. Do you see the same in your test?
Is your main goal to export customers from specific segments or do you have other steps from there? I’d be happy to dig in to see if this is the best query or if we can find something that may work better!
But why it is gid://shopify/CustomerSegmentMember/integer rather than gid://shopify/Customer/integer? I am hesitant to treat it as customer id that integer could be referring to some other objects instead of Customer.
I am trying to export store credit from a specific segment efficiently, but currently the only method to pull store credit for a list of customer is to do API call to get store credit one by one with id or email.
That’s a valid hesitancy since the fields aren’t documented as 1:1.
What I would recommend here is to set up a Flow automation to add and remove tags from customers when they are in certain segments. This way you can query customers with certain tag.
Why shopify doesn’t just expose the customer id to make life easier to avoid having to do an extra lookup for customers. This also causes issues by making customers without email impossible to work with from the query result since customer id is missing!
Unmarked it as solution because flow automation and tag is not scalable and very cumbersome to work with compared to a very simple fix by shopify to expose the customer id on the graphql result.
Please confirm if this is the case because I have some time sensitive customer segment query to be finished which is blocked due to inefficiency for having to run an extra unnecessary query to get customer id unless I can use use the gid://shopify/CustomerSegmentMember/CUSTOMER_ID directly by replacing CustomerSegmentMember with Customer so that it can become gid://shopify/Customer/CUSTOMER_ID
Thanks for that feedback on the customer IDs within segments. I have passed that on for you to make the relationship more clear as well as suggestion to just use the customer GID. Any changes to the current functionality will be noted in the developers changelog
In the meantime, as you’ve found, the customerID and customerSegmentMember are are currently 1:1 using same ID, just as it was back in 2022 in that post so it should be safe to finish your segment queries without cumbersome workarounds.