How To Add JavaScript To An Individual Shopify Page – Step By Step

Eddy Chung

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:

  1. Go to your Shopify Admin and go to Online Store
  2. Click Actions > Edit Code
  3. Under your Templates folder, select Add a new template
  4. Choose the type of page you want the JavaScript to be added to. I will choose page as an example.
  5. Click Create template
  6. At the bottom of this file, include your JavaScript. Be sure to wrap it in <script></script> tags. I added a simple alert.
  7. Go to Page and Add or edit a page.
  8. In the page editor on the right-hand side, select the new template you just created.
  9. Test your page out! The JavaScript you wrote should be working.
  10. If you want this to apply to multiple pages, change the templates of the other pages you want the JavaScript to run on.