How to get the customer_id from a ScriptTag

New Member
2 0 1

Hi, We're working on an app that needs to connect our service with stores and match-up shopify customers with our user accounts. We authenticate fine, and can query various APIs, however we're unclear on how our Javascript scriptTag can determine the shopify customer id, in order to pass that to our service. We're also unclear how we might detect when the user transitions from being anonymous to logged into the shopify store.


Many thanks,


PS. Previous posts on the subject seem to be out of date

Shopify Staff
Shopify Staff
1555 81 293

You could try using theme code to capture the customer ID with liquid, storing it in a variable for use by your script tag:


// Theme code
  var customerId = {{ }};

// ScriptTag