Join us for an upcoming Shopify Partner webinar on February 27, 2024. Discover the latest Checkout Extensibility features, and deep dive on improvements to Shopify Functions and Web Pixels. Register now for either the 10am EST or 2pm EST sessions.

Access shop variables and use Liquid inside javascript files

Shopify Partner
18 0 4

Hey Shopify Community 😏


I'm trying to access shop variables like shop.url & inside of an external Javascript file.


I successfully made a script which I've placed between script tags inside of a section file, but I'm trying to clean up my code and reduce the amount of <script> tags I have, so I'm wondering if there's a way to include the .js.liquid file inside of my theme.liquid head, while still maintaining functionality of the liquid?


Usage: I'm creating logging for my themes to get better insight on who uses my themes, mainly to prevent piracy... but that's not the point of this post.


If you have any tips/solutions, don't hesitate to help!



- grim 😀

Reply 1 (1)

Shopify Staff
2685 288 737

Hi Grim,


Unfortunately global variables like the store url or theme name are not accessible in js.liquid files - you can only use the `settings` object and Liquid filters in these js.liquid files. See our docs on this here.


I'll log this as a feature request though!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit or the Shopify Web Design and Development Blog