Skip to content
Help
Builder design and settings

How do I add custom JavaScript to my whole store?

Add your own JavaScript to every page of your store with the builder Custom Javascript tab. When the code runs, why it does not run again on each page, errors, and why tracking tags and verification codes belong in apps instead.

3 min read

The Custom Javascript tab runs your own JavaScript on your store. Use it for small behaviors that the builder settings and apps do not cover.

Where to find it

Open the builder, click the gear icon, and open the Custom Javascript tab. The box is called Javascript code: Applies to the entire store. Paste your code without <script> tags. Write plain JavaScript only.

When your code runs

  • It runs once when a shopper opens your store, after the page is shown.
  • It does not run again on every page. When a shopper moves to another page inside your store, the page changes without a full reload, so your code is not run a second time. If your code changes elements on one page, make it handle page changes, or use a Custom code section on that page instead.
  • In the builder preview, the code runs too, and runs again when you change it.
  • Your code runs in its own space, so names you declare do not clash with the store. If your code throws an error while it runs, the error is caught and does not break your store. The error is hidden, so if nothing happens, test your code step by step.

Use an app instead when you can

Many scripts merchants paste here have a dedicated app that does the job better:

  • Facebook, TikTok, Snapchat, Pinterest, X, or Google Ads tracking: use the pixel apps. See Pixels and conversion API.
  • Google Analytics or tags you manage in Google Tag Manager: use the Google Tag Manager app.
  • Verification codes for Google Search Console, Meta, TikTok, or Snapchat: use the Domain Verifier app. Code in this tab does not reach the head of your page the way verification needs.
  • Live chat: see Crisp live chat.

These apps send events such as purchases at the right moment for you.

Store-wide code or a Custom code section

  • Custom Javascript tab: every page, runs once per visit.
  • Custom code section: one page, with its own HTML, CSS, and JavaScript, and it runs each time that section is shown. See Custom code.

Tips

  • Never paste secret keys or passwords. Anyone can read this code in their browser.
  • Test on your live store on a phone and a computer after you publish.
  • Third-party scripts can slow your store. Add only what you need.
  • If something breaks, empty the box, publish, and add your code back piece by piece.
  • An AI assistant connected to your store needs your permission to change custom code. See Manage assistant access.

Good to know

Custom Javascript belongs to the market you are editing. Repeat it in every market that needs it. Changes go live when you click Publish.

Still need help?

Write to us and we will answer you.

Contact us