Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Re: Custom web pixel: missing data

Why is customer data missing in custom web pixel implementation?

dhpwd
Shopify Partner
3 0 6

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)

 

customer-obj.jpeg

 

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

 

event-obj.jpeg

 

This appears to be a bug?

 

Thanks,

 

Dan

Founder at Drivn
https://drivn.co/
Replies 8 (8)

f54ba3n
Shopify Partner
3 0 1

Same here. Did you find a solution?

guimei
Shopify Partner
18 0 5

Same here. Did you find a solution?

serkanersan
Visitor
3 0 0

I have the same problem..

dnv
Shopify Partner
1 0 0

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?

MinhLeos
Shopify Partner
14 0 0

Hi, i have the same problem. Do you have a solution yet? Can you share it with me?

gam_analytics
Shopify Partner
2 0 0

I don't even see the customer object

jhoncortes
Shopify Partner
1 0 0

Hello @dhpwd.  

 

Have you found any solution to get the Customer ID in checkout_completed?

 

ShopifyDevSup
Shopify Staff
1453 238 522

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