Web Pixel init data for logged in customer showing undefined ordersCOunt

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?

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