The script tags are not being loaded in the store even though the configuration seems to be correct.

Highlighted
New Member
1 0 0

Hi everyone, how are you? I'm having some issues related to Script Tag.

 

I've been following the instructions in https://github.com/Shopify/shopify_app#scripttagsmanager but it's not working. My current shopify configuration is: 

ShopifyApp.configure do |config|
  config.application_name = ENV['NAME']
  config.api_key = ENV['SHOPIFY_API_KEY']
  config.secret = ENV['SHOPIFY_API_SECRET']
  config.scope = "write_products, write_script_tags"
  config.embedded_app = true
  config.after_authenticate_job = false
  config.api_version = "2019-10"
  config.session_repository = Shop
  config.scripttags = [
    {event: 'onload', src: "https://96ed3ef4.ngrok.io/scripts/hello.js"}
  ]
end

When I install the application everything seems to be working correctly. I am also able to get the newly created script tags by using:

 

scripttags = @shop.with_shopify_session do
  ShopifyAPI::ScriptTag.all
end

The variable scripttags contains:

 

[#<ShopifyAPI::ScriptTag:0x00007f4b201a8e30
  @attributes=
   {"id"=>111452946541,
    "src"=>"https://96ed3ef4.ngrok.io/scripts/hello.js",
    "event"=>"onload",
    "created_at"=>"2020-01-15T15:48:59-05:00",
    "updated_at"=>"2020-01-15T15:48:59-05:00",
    "display_scope"=>"all"},
  @persisted=true,
  @prefix_options={}>]

But I'm not seeing the `hello.js` file being loaded in the store.

 

 

I've tried creating the script_tag manually by using:

ShopifyAPI::ScriptTag.create(event: "onload", src: "https://96ed3ef4.ngrok.io/scripts/hello.js")

 

and I'm having the same result.

 

Some extra information:

I will be immensely grateful for any help/suggestion.

 

Best,

Rafael

0 Likes
Shopify Partner
1348 156 239

That is odd. Can you share a preview URL to your store?

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes