Current best way to get logged in customer id

15 0 2

I'm looking for some advice on the best way to get the current logged in customer id. Right now I rely on app proxy pages, but I'm not really happy with that solution. I've seen people use some Javascript supplied by Shopify to check a variable:



But it doesn't seem like it's intended to be used by developers and could change without notice. What solutions are people finding the most success with? Are there any plans to have better support for this in the near future?

1 Like



You can use liquid for the same. You can get current user's customer id by => {{ }}

Have something to say? Or need to say Hi! just mail me at or visit
1 Like
New Member
1 0 0

Hi Sagar,


Can I also use this in a HTTP response from a proxy URL if the Content-Type is set to 'application/liquid'? My response relies on the customer that is currently logged in.

Shopify Partner
40 0 1

Hi, Davie_w

I think the __st.cid is a good solution. 

If you want to make sure the logged customers data is correct. You can use the ScriptTag API to achieve.


1. Add a script resource to store via ScriptTag API

2. In the script use the __st.cid to get the current customer's ID

3. Save the result from the step.2 in browser's localstorage and your app can access it


Does it work for you?

Shopify Partner
40 0 1

My above solution might have some issue. 

The cid save in the localstorage will meet the issue of different.

If your app is embed via ScriptTag, I think the best solution is using the Post Message way to transport the cid between two domain.