How to Identify Merchant Store that App Script is Running from?

20 0 3


Hey, Shopify App Experts

Need some help with an embedded Shopify App. We have an App where we store some merchant configuration details in a DB (Firestore) for example:

merchantConfigs {
  message: String;
  enabled: Boolean;

  shopOrigin: String; // merchant shopify origin, Eg.



To find out whose store this configuration belongs to, we query by the merchants shopOrigin. Seems like a sensible way to identify merchants in our database.

The issue is we also need to inject a script tag (using Shopify's script_tag API) into the merchant customer's storefront. The client (site visitor) needs to retrieve this configuration from our database. We resolve this by having a separate API endpoint and supporting `jsonp`. The problem is: how do we identify the merchant's store from the website script. I see two ways to solve this:

1. Somehow get the stores shopOrigin using clientside javascript. Not sure how to do this yet. Is it passed through Liquid's templates?

2. Provide a way in our embedded app for the merchant to enter in his official domain name. Then on the client script, we can just request the resource, and our server will extract the domain name from the request connections object (we're using Node). Then we use the domain name to query the configuration details instead of the shopOrigin.

Are there any other ways to do this more gracefully? Exchanging data between Shopify App and Shopify Storefront feels like a bit of a hack in general. There has to an easier, officially support method, right?