Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi there,
Context: we're implementing a custom web pixel (https://help.shopify.com/en/manual/promoting-marketing/pixels/custom-pixels), starting with the checkout_completed event
Problem: we're not able to access the customer's ID, first or last name
Customer ID: we're looking at the init.data.customer object (per https://shopify.dev/docs/api/pixels/pixel-extension#web-pixel-api-reference) however all fields are undefined (see below)
The event object (https://shopify.dev/docs/api/pixels/customer-events#event-structure) contains clientId however this is an anonymous ID generated by the client, not the customer ID
First/last name: these should also be set on the same customer object, as well as on the event.data.checkout.shippingAddress object per https://shopify.dev/docs/api/pixels/customer-events#mailingaddress however they're missing from both
This appears to be a bug?
Thanks,
Dan
Same here. Did you find a solution?
Same here. Did you find a solution?
I have the same problem..
In my case, the pixel sent event page_viewed on page "thank you". but not send the checkout_completed. Is there any solution on this?
I don't even see the customer object
Hi! The Customer ID on the `checkout_completed` event is accessible within `event.data.checkout.order.customer.id`, for example;
```
analytics.subscribe('checkout_completed', (event) => {
console.log("event", event)
const customerId = event.data.checkout.order.customer.id
console.log("customerId", customerId)
})
```
The customer's first and last name should also be accessible within either the `event.data.checkout.shippingAddress` and/or `event.data.checkout.billingAddress`.
`init.data.customer` requires the customer to be logged-in on the storefront or the checkout, in order to be able to access the associated Customer object and Customer Account on the shop - perhaps this explains why you were not seeing any customer data in that case?
Hopefully this helps! Please let us know if anything else is still unclear here or if you have any other feedback regarding this.
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024