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
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024