A space to discuss online store customization, theme development, and Liquid templating.
Hello there!
There are a few ways to insert a script directly into a Shopify theme or use the DOMContentLoaded event for the scriptTag:
hope this helps!
If this fixed your issue, likes and accepting as a solution are highly appreciated.
Build an online presence with our custom built Shopify Theme EcomifyTheme
Thanks for the response,
using option 1 and 5 are not an option for us as we're trying to do this through our Shopify app FigPii,
Regarding using ScriptTag API based on the documentation provided here ScriptTag the only value allowed for 'event' is onload which is too late. How can we set this to DOMContentLoaded?
The load / onload event is too late as it waits for all content to be download (images, subframes, etc).
Thanks for your help!
I'm currently working on this same problem. I'll update when I figure something out!
Curios, if there has been any update here? We have also seen "complaints" from merchants that our script takes long to load because it waits until the full page is loaded and the onload event gets triggered.
It will be great if there is support for the DOMContentLoaded event (https://developer.mozilla.org/en-US/docs/Web/API/Document/DOMContentLoaded_event), especially for tracking-type scripts which don't leave any visual footprint on the site.
The only workaround we identified was to have merchants manually add the <script> to their head tag, and we updated our app to delete the existing script tag. This circumvents the `asyncLoaded` function.
Hi @rheannonedev ,
That makes sense, thanks for the quick feedback.
It doesn't make really sense for us as it would require manual code/template changes for the merchant which is the reason we built the app. 😕 We added it to our list of known Shopify issues. Luckily it doesn't affect too many of merchants (as far as I know) but we have seen it a couple of times where the tags are loaded 30s or even later.
It seems the push is towards web/server pixels and checkout extensions anyway.
I learned that the script tags run in chronological order, so if the merchant has a lot of apps installed before yours, it will take longer.
Thanks, that's a good insight, but probably tough to tell advertisers to uninstall all apps and then re-install apps and ours first. 😉