Sha256: e1e7795e1ea6db7cf849ed6451f423fc8a4a6efca5f4f72a75e876618c276ceb

Contents?: true

Size: 1.08 KB

Versions: 38

Compression:

Stored size: 1.08 KB

Contents

# ScriptTags

#### Table of contents

[Manage ScriptTags using the Shopify App initializer](#manage-scripttags-using-the-shopify-app-initializer)

## Manage ScriptTags using the Shopify App initializer

As with webhooks, ShopifyApp can manage your app's [ScriptTags](https://shopify-dev-staging.shopifycloud.com/docs/admin-api/graphql/reference/online-store/scripttag) for you by setting which scripttags you require in the initializer:

```ruby
ShopifyApp.configure do |config|
  config.scripttags = [
    {event:'onload', src: 'https://example.com/fancy.js'},
    {event:'onload', src: ->(domain) { dynamic_tag_url(domain) } }
  ]
end
```

You also need to have write_script_tags permission in the config scope in order to add script tags automatically:

```ruby
 config.scope = '... , write_script_tags'
```

Scripttags are created in the same way as the [Webhooks](/docs/shopify_app/webhooks.md), with a background job which will create the required scripttags.

If `src` responds to `call` its return value will be used as the scripttag's source. It will be called on scripttag creation and deletion.

Version data entries

38 entries across 38 versions & 2 rubygems

Version Path
ruby_shopify_app-1.3.3 docs/shopify_app/script-tags.md
ruby_shopify_app-1.3.2 docs/shopify_app/script-tags.md
ruby_shopify_app-1.3.1 docs/shopify_app/script-tags.md
ruby_shopify_app-1.3.0 docs/shopify_app/script-tags.md
ruby_shopify_app-1.2.0 docs/shopify_app/script-tags.md
ruby_shopify_app-1.1.0 docs/shopify_app/script-tags.md
shopify_app-21.10.0 docs/shopify_app/script-tags.md
shopify_app-21.9.0 docs/shopify_app/script-tags.md
shopify_app-21.8.1 docs/shopify_app/script-tags.md
shopify_app-21.8.0 docs/shopify_app/script-tags.md
shopify_app-21.7.0 docs/shopify_app/script-tags.md
shopify_app-21.6.0 docs/shopify_app/script-tags.md
shopify_app-21.5.0 docs/shopify_app/script-tags.md
ruby_shopify_app-1.0.0 docs/shopify_app/script-tags.md
shopify_app-21.4.1 docs/shopify_app/script-tags.md
shopify_app-21.4.0 docs/shopify_app/script-tags.md
shopify_app-21.3.1 docs/shopify_app/script-tags.md
shopify_app-21.3.0 docs/shopify_app/script-tags.md
shopify_app-21.2.0 docs/shopify_app/script-tags.md
shopify_app-21.1.1 docs/shopify_app/script-tags.md