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?
Hi, i have the same problem. Do you have a solution yet? Can you share it with me?
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
The year-end shopping spree is around the corner! Is your online store ready for the ...
By JasonH Nov 10, 2024We recently spoke with Zopi developers @Zopi about how dropshipping businesses can enha...
By JasonH Oct 23, 2024A big shout out to all of the merchants who participated in our AMA with 2H Media: Holi...
By Jacqui Oct 21, 2024