skip to Main Content

As i am new to shopify app i created an app and installed over a store with script tag having read and write permission . How can i dynamically add the javascript to the front side of shopify app.

2

Answers


  1. Use the Script Tag API to create the javascript you want to load dynamically.

    # POST /admin/script_tags.json
    
    {
      "script_tag": {
        "event": "onload",
        "src": "https://djavaskripped.org/fancy.js"
      }
    }
    

    Documentation: Link

    Login or Signup to reply.
  2. When your App is installed in a Shop, the merchant usually gets two dialogs to confirm. One is if you are asking for a billing charge. The other is for the scopes access to their shop. Assuming they approve both, you will get an oAuth token allowing you to read/write ScriptTag endpoint.

    So when you get that oAuth token, you save it along with the shop name, and that is finally when you can POST your script tag payload in the store.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search