Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Clarity about App Embed Blocks, External Dependencies and Cookies

Solved

Clarity about App Embed Blocks, External Dependencies and Cookies

debugagent
Shopify Partner
5 0 1
I’m working on an App embed block which includes a floating chat window in the store. Some of the policies related to this aren’t clear to me.
  • Can my liquid code include a JavaScript file from our servers?
  • Can that script file trigger an HttpOnly cookie so I will be able to identify the user uniquely?
I know cookies aren’t allowed but this seems to be related to the embedded app part, not for a completely separate server.Assuming the latter isn’t legal, how can an app embed get access to user identity?
Accepted Solution (1)
Liam
Community Manager
3108 342 884

This is an accepted solution.

Sure - so communication between the app extension and the backend could be achieved using App Proxies to forward requests directly to your app's server. There's more info on how app proxies can be used in our dev docs here.

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

View solution in original post

Replies 7 (7)

Liam
Community Manager
3108 342 884

Hi Debugagent,

 

With theme app extensions, your app can contain Javascript files within the `/assets` subdirectory which is then automatically rendered by Shopify's own CDN - so you should be able to use that file to load scripts that you need. However you can't include external JS files or libraries.

 

Hope this clarifies things!

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

debugagent
Shopify Partner
5 0 1

So how do I connect that to my backend code?

This is really unclear from the rating app sample. Say in a chat app like intercom. The logic is in the intercom servers and the database. But the frontend code is JavaScript, how can I connect everything and maintain user identity.

Liam
Community Manager
3108 342 884

This is an accepted solution.

Sure - so communication between the app extension and the backend could be achieved using App Proxies to forward requests directly to your app's server. There's more info on how app proxies can be used in our dev docs here.

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

debugagent
Shopify Partner
5 0 1

I think my app can't be built under these restrictions. Please correct me if I'm wrong.

 

I have a chat and I want to invite a friend to a chat. I send him a URL to join and he does. Then our chat history is kept. I can do everything in this but I can't store the identity of the friend that joined unless he logged-in. Worse, I can't even store my own identity unless I'm logged-in to shopify.

 

Is that a correct assessment?

Liam
Community Manager
3108 342 884

Hi again Debugagent - for your use case the current model of theme app extensions may not be comprehensive to achieve what you need. Will this app be a public app available on the Shopify App Store? If not you could explore using the ScriptTag resource of the Admin API, or the Asset API which give you a lot more control around options for integrating with themes. However, both of these are subject to limitations of use if the app is available on the Shopify App Store - and you may not pass the app review process if you're using these. 

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

debugagent
Shopify Partner
5 0 1

Thanks. The goal is to ship via the store but I guess this particular type of app isn't possible in that channel.

Girish_Rajwani
Shopify Partner
82 3 8

hey @Liam ,

 

thanks a lot for your informative comments, can you please provide below info?

1. I am building app and want to show that functionality on collection & cart page(app block is not supported in collection grid & cart items) but creating snippet is not allowed, so what to do in that case  ?

 

2. Also if merchant is not using online store 2.0 then what to do in that case ? should we create snippet with code OR provide merchant with onboarding instruction ?

Girish | Shopify Expert  
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - My Shopify Apps: App Store | Looking for a solution to a problem in your store? Send me an email