For discussing the development and usage of Checkout UI extensions, post-purchase extensions, web pixels, Customer Accounts UI extensions, and POS UI extensions
I'm checking `init.data.customer` in a custom Web Pixel to get the `ordersCount` for the purpose of detecting repeat customers, but it is coming back as `undefined`. The customer is logged in, has orders, and all fields (`email`, `firstName`, etc.) are populated correctly, except for `ordersCount`.
Has `ordersCount` been deprecated or is there another reason why it may be `undefined`?
Solved! Go to the solution
This is an accepted solution.
Following up to share that we were seeing `undefined` because all orders in the accounts we checked were test orders (we were testing on our staging shop), which are not counted. After creating manual orders, we see the value populated correctly for logged in customers.
This is an accepted solution.
Following up to share that we were seeing `undefined` because all orders in the accounts we checked were test orders (we were testing on our staging shop), which are not counted. After creating manual orders, we see the value populated correctly for logged in customers.
Hi @jc45, i also got the problem with the value undefined.
The Shopify Support told me to get the data with: event.data?.checkout?.customer?.orders_count in the custom Pixel. But sadly it doesnt work.
Could you tell me how you get the ordersCount in the web pixel?
You can use
init.data.customer?.ordersCount
In custom pixels, init is a global variable. It's documented here: https://shopify.dev/docs/api/web-pixels-api/standard-api/init