Sometimes you need to add JavaScript to a single or a group of pages in Shopify either for tracking or to add a certain behavior.
To add JavaScript to an individual or group of Shopify pages:
- Go to your Shopify Admin and go to Online Store
- Click Actions > Edit Code
- Under your Templates folder, select Add a new template
- Choose the type of page you want the JavaScript to be added to. I will choose page as an example.
- Click Create template
- At the bottom of this file, include your JavaScript. Be sure to wrap it in <script></script> tags. I added a simple alert.
- Go to Page and Add or edit a page.
- In the page editor on the right-hand side, select the new template you just created.
- Test your page out! The JavaScript you wrote should be working.
- If you want this to apply to multiple pages, change the templates of the other pages you want the JavaScript to run on.




