Custom Pixels checkout_completed - Differentiating New and Returning Customers

Custom Pixels checkout_completed - Differentiating New and Returning Customers

jspanom
Shopify Partner
2 0 1

 

Hello everyone,

 

I am currently facing a challenge with Shopify's Custom Pixels, specifically in the context of the checkout_completed event. Our marketing team finds it crucial to distinguish between orders made by new versus returning customers, and I'm in search of a method to obtain this context.

 

Despite logging all the information provided by the Shopify API in relation to the custom pixel, I'm unable to find details regarding whether a user is new or returning, their number of orders, or even their user ID.

To clarify, by "returning user," I mean someone who has previously placed an order, and a "new user" is one placing their first order in our store.

 

Here's the code snippet where I log the information:

 

analytics.subscribe("all_events", async (event) => {
  let event_name = event.name;
  console.log("event_name:", event_name);
  let event_client_id = event.clientId;
  console.log("event_client_id:", event_client_id);
  let event_id = event.id;
  console.log("event_id:", event_id);
  console.log("-");
  let event_context = event.context;
  console.log("event_context:", event_context);
  let event_data = event.data;
  console.log("event_data:", event_data);
  console.log("-");
  let init_context = init.context;
  console.log("init_context:", init_context);
  let init_data = init.data;
  console.log("init_data:", init_data);
  console.log("------------------------------");
});

 

 

Am I overlooking something, or is it possible that this information really isn't available? I find it surprising that this issue hasn't been a common topic of discussion.

 

The only alternative I can think of is implementing a custom event and retrieving the necessary data from the Shopify GraphQL admin API.

 

Any guidance or support on this matter would be greatly appreciated.

Thank you in advance.

Replies 6 (6)

lstellway
Shopify Partner
5 0 5

I'm in search of an answer to this as well.. 

Using the checkout_completed event, my best guess was to use the `event.data.checkout.transactions` property - I'm not entirely sure what that is, but it doesn't seem to be what I need. 

jspanom
Shopify Partner
2 0 1

It's strange that the customer id at least is not available.

I had to create a custom proxy that receives the order id and email, and returns the customer id and the users orders from the Shopify Rest API.

Liam_WG
Shopify Partner
2 0 0

Do you have a snippet of the code you used to do this? I'm trying to achieve a similar thing

DenTok
Shopify Partner
18 0 10

The only way I found to distinguish a returning customer is by using the `init.data.customer.ordersCount`, which is defined only when the customer si logged in. Hope it helps! 

solar443
Visitor
3 0 0

Hi, true but it doesn't seem to work in the post purchase page

Luca_Lavorato
Shopify Partner
3 0 0

Any updates on this front?

 

Would be ideal to be distinguish new from returning, or be able to get the order count ON the checkout_completed event, and any events that happen while the customer is logged in and identifiable.