cookiewow-logo
HomeUser GuideHow to Install a Cookie BannerHow to add script to Shopify

How to add script to Shopify

Category:How to Install a Cookie BannerUpdated at: 23/09/2026

1. Add Script to All Pages (Theme Code)

Use this method if you're embedding JS across the whole store (e.g., Google Analytics, custom events):
Steps:

  1. Go to Shopify Admin → Online Store → Themes

  2. Click Actions → Edit code

  3. Open: layout/theme.liquid

  4. Insert your script before the closing </head> or </body> tag:

liquid
CopyEdit<!-- Example: Custom Script -->
<script>
  console.log("Custom script loaded");
</script>
  1. Click Save

2. Add Script to Specific Page (e.g., Product Page Only)

Open the file you want (e.g., product.liquid, product-template.liquid, or main-product.liquid) and add your script there.

liquid
CopyEdit{% if template == 'product' %}
  <script>
    // Custom product page logic
  </script>
{% endif %}

3. Use Shopify’s Customizer (Settings > Custom Liquid)

Shopify themes (2.0+) may allow Custom Liquid blocks:

  1. Go to Online Store → Themes → Customize

  2. Choose the page template

  3. Click Add block/section → Custom Liquid

  4. Insert your script like this:

liquid
CopyEdit<script>
  console.log("This script runs on the homepage only.");
</script>

4. Add Script via Shopify Admin (Checkout)

If you're on Shopify Plus, you can customize the checkout:

  • Go to Settings → Checkout → scroll to Order Status Page

  • Paste your script under Additional Scripts

5. Use Shopify Apps

For things like Facebook Pixel, Google Analytics, etc., Shopify recommends installing their official apps or integrating via Shopify > Settings > Customer Events.

Related articles

See all

Need more help?

Get in touch and we'll help solve it

Chat with usEmail us