Using AppProxies or ScriptTags

Shopify Partner
31 0 12

I'm a Shopify Partner building a new app.


To install our app, we need the Merchant to manually insert some Liquid code into their theme. However, instead of doing it that way, the person from Shopify who reviewed our app (to list it in the App Store) recommended that we use AppProxies or ScriptTags for that -- so it automatically inserts the Liquid code rather than requiring a manual change.


Can someone help me understand how to use AppProxies or ScriptTags for those purposes? I have read the documentation online, but I still don't understand how to use them in that way.

5 0 0

Hi, I'm having the same exact problem!
I need to insert a snippet of code into the store's theme, I'm able to achieve that in my test store with this following code:

@themes_id = ShopifyAPI::Theme.find(:all)
      @themes_id.each do |t|
        layout = ShopifyAPI::Asset.find('layout/theme.liquid', params: { theme_id: })
        ShopifyAPI::Asset.create(key: "snippets/aplicatify-snippet.liquid", 
        value: "My snippet Code")
        unless layout.value.include? "{% include 'aplicatify-snippet' %}"
          l = layout.value.split('<head>')
          layout.value = "#{l[0]}\n<head>\n  <!-- APLICATIFY:START -->\n {% include 'aplicatify-snippet' %}\n  <!-- APLICATIFY:END -->\n#{l[1]}"


This works on my test store, but when I submit the app for review this piece of code fails. It fails even if insert nothing into the 'layout/theme.liquid'. I receive a bad request error: 783 and the review process fails


Shopify Partner
31 0 12

Thanks for your reply. I'll tell you if I get an answer. I asked my reviewer for help as well, but I'm not sure reviewers help in that way.