Help Making App That Adds JS Code To Theme Files

Help Making App That Adds JS Code To Theme Files

Shopify Partner
24 0 4


 I have written some JavaScript code that redirects new users to the checkout page after they've created an account. I'm currently using this piece of code in all 5 Shopify stores I own. I would like to create an app that simply pastes the JavaScript code in the index.liquid, login.liquid and accounts.liquid files of whatever store it's installed in.

I'm not that much of a programmer but I'm pretty good at finding pieces of code online and meshing them together to get them to do what I want. I've already set up a basic Shopify App that displays information and I've installed it on a development store using this guide

Now what I would like to do is have the app automatically paste the JavaScript code in the index.liquid, login.liquid & accounts.liquid when it's installed to a store. Any help on how I can do this?

Replies 2 (2)

Shopify Partner
137 16 62

Hey @EphraimMulilo 

best way to start is to look at the docs on

The docs are pretty extensive. But basically what you want to do is when the app installs, access each one of those specific files using the Admin API and the Themes endpoint.

Each of the liquid files are Assets. So just look up each one and make the changes to the value. Pretty easy!

Was this helpful? Press like!
Did it fix the problem? Mark it as the solution for others!
Buy me a beer? Well, sure!
Shopify Partner
1 0 0

i had a similar use case, what i am trying to do is, when user installs my app, in page, i would ask for a token from user, which i will use in a static js code which is just an embed script. I then need to add this embed script to user's main theme.liquid file's header. Can you please guide me a bit, i am currently done with the frontend part. Still stuck in the backend flow