Unique identifier for Guest customer

Unique identifier for Guest customer

arnav98
Shopify Partner
26 1 7

Hi,

 

I am trying to find a way to store some unique id of a guest customer/visitor to the store to maintain a record of the interaction of the guest user against their activity on the store in the "app embed block" so if a guest comes back then I can show their past activity on the store.

 

The "{{ customer }}" object is empty when the user is not logged in, so I am only facing an issue for storing the activity of the guest customer, if and how does Shopify track guest customers, using localStorage/sessionStorage, or cookies?

I really appreciate any help you can provide.

Replies 2 (2)

Liam
Shopify Staff
2873 312 821

Hi Arnav98,

 

Unless a customer is logged into their customer account there's no native way to distinguish which customer is returning vs being a new customer. So you will be able to set up logic with Liquid based on the customer object (and potentially customer tags) to show past activity, but an unlogged in customer is essentially viewed as anonymous with Liquid/ Storefront API, so the past activity won't be natively accessible. 

 

You could potentially use JavaScript to set and read cookies or utilize localStorage/sessionStorage in the user's browser, but you'll need to ensure this is set up to comply with any data privacy considerations. 

 

Hope this helps!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me 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

delivrai
Visitor
1 0 0

Liam, 
Quick follow up question, I am building a shopify app for my platform. I would like to connect the anonymous session id or in the case of Arnav98's question the unknown "customer" session to my endpoint call.   I legally de-anonymize website traffic and integrate that into other applications, such as Twilio Segment or Adobe CDP.  It could be as simple as passing the id to me as described in the link below. 
https://docs.delivr.ai/docs/resolution-pixel/associating-resolutions-to-users

That being said I have created a temporary guide for an ad hoc integration but am unsure of what api merge field to embed into my end point call. My current integration is below and seems to work but it is not linking the anonymous session to the resolved PII. Ideally I would want to write that data back to shopify so the store may be able to remarket directly to the details of the abandoned cart using any channel they choose; email, sms, ads, etc...
https://docs.delivr.ai/docs/resolution-pixel/shopify-store-installation-guide

Sincerley, Gregory gk@delivr.ai