Hello, we are trying to make a shopify application for our currently live project. Our application generates an embed code (a simple js file) and we expect our users to add it to their sites. For this, I am currently using the script tag api. Do I need to migrate to app extension? In which cases should I use an application extension?
Topic summary
A developer is building a Shopify app that generates an embed code (JavaScript file) for users to add to their sites. They’re currently using the Script Tag API and wondering whether to migrate to app extensions.
Recommendation provided:
- App extensions are the preferred solution for cleanly and safely injecting tags in Shopify 2.0 themes
- Theme app extensions offer better integration than the Script Tag API
Implementation guidance:
- Create app-embed blocks within the theme extensions folder of the application project
- Key configuration includes setting the “target” field to “body” in the schema
- Reference fields: stylesheet, javascript, settings array
- Documentation links provided for app CLI structure, theme app extensions, and app-embed blocks
Status: Question answered with technical direction provided, but no confirmation of implementation from the original poster.
Yea, based on the documentation suggestions creating an extension appears to be the best solution to “cleanly”/safely inject tags based on 2.0 themes.
be sure to read up on the app-building documentation here: https://shopify.dev/docs/apps/tools/cli/structure
https://shopify.dev/docs/apps/online-store/theme-app-extensions
Inside the theme extensions block folder (within the application project) you will create something like this:
{% schema %}
{
"name": "Your Name",
"target": "body", // THIS IS IMPORTANT
"stylesheet": "file-name.css",
"javascript": "file-name.js",
"settings": []
}
{% endschema %}