This article is part of our complete Wix guide.
Sooner or later most site owners need to add custom code to Wix: a verification tag from a tool, a chat widget script, a booking embed from a third-party service, a tracking pixel or a bit of HTML a partner sent over. Wix gives you several places to put code, and each behaves differently. Paste a script in the wrong place and it either does nothing or slows down every page. This guide explains the options, shows exactly when to use each one, and covers the problems people run into most.
Key takeaways
- Site-wide scripts belong in the dashboard Custom Code settings, placed in the head or body and applied to all or selected pages.
- The Embed HTML element shows code in a sandboxed frame on one page; it cannot change the rest of the page.
- Use Wix’s Marketing Integrations for Google Analytics, Tag Manager and common pixels instead of pasting raw code.
- For interactive features that change page elements, use Velo rather than embedded scripts.
- Custom code features generally need a premium plan and connected domain; check Wix’s current requirements.
In this guide
- The different ways to add code to Wix
- How to add scripts to the head or body of a Wix site
- How to use the Embed HTML element
- Adding tracking codes and pixels
- Velo, custom elements and custom CSS
- Why is my custom code not working on Wix?
- Common mistakes and a safety checklist
- Need help with custom code? Let MIVAQ do it for you
- Frequently asked questions
The different ways to add code to Wix
Wix is a hosted platform, so you cannot edit theme files the way you would on WordPress. Instead, Wix offers controlled entry points. Choosing the right one is the most important decision:
| Method | Where code runs | Best for |
|---|---|---|
| Custom Code (dashboard settings) | Head or body of the real page, site-wide or selected pages | Verification tags, chat widgets, third-party scripts |
| Embed HTML element | Inside a sandboxed iframe on one page | Booking widgets, calculators, forms from other tools, maps |
| Marketing Integrations | Managed by Wix | Google Analytics, Tag Manager, Meta Pixel and similar |
| Velo (Dev Mode) | Page, site and backend code with Wix APIs | Interactive features, data, custom logic |
| Custom element / custom CSS | Web components and stylesheet (Velo / Wix Studio) | Advanced UI and styling beyond the editor |
A simple rule: if the code needs to affect the whole page or track visitors, use Custom Code or Marketing Integrations. If it should display something in one spot, use Embed HTML. If it needs to interact with Wix elements or data, use Velo by Wix.
How to add scripts to the head or body of a Wix site
The Custom Code feature lives in your site dashboard under Settings, in the advanced or developer section (Wix occasionally moves menu items). Wix’s Help Center article on embedding custom code has the current location and requirements. The process looks like this:
- Copy the snippet from the service you are adding, exactly as provided.
- Open your dashboard, go to Settings and find Custom Code.
- Click to add custom code and paste the snippet.
- Name it clearly, for example “Hotjar – all pages” or “Chat widget – contact page”, so you know what it is later.
- Choose pages: all pages, or specific pages only. Load scripts only where they are needed.
- Choose loading behaviour: load once per visit or on each new page, depending on the vendor’s instructions.
- Choose placement: head, body start or body end. Vendors usually tell you; when they do not, body end is the safest for performance.
- Save and publish your site, then test on the live domain (not just in Preview).
Some scripts only work on the published, connected domain, which is why testing on the live URL matters. Use your browser’s developer tools to confirm the script loads, and check the vendor’s dashboard for a “connected” status.
How to use the Embed HTML element
To show third-party content in a specific spot, add an Embed element from the editor’s Add panel (look for Embed Code, then Embed HTML). Paste your code or a URL, then resize the box on the canvas.
The key thing to understand is that Embed HTML runs inside an iframe. That keeps your site safe and stable, but it also means:
- The code cannot change other elements on your page or read your page’s content.
- The frame has a fixed size you set in the editor, so content longer than the box gets cut off or scrolls. Set a generous height and check the mobile view separately.
- Content inside the frame is generally not treated as part of your page by search engines, so do not put important SEO text in an embed.
- Scripts that expect to sit in the head of the page, such as analytics, will not track your site properly from inside an embed.
Embeds are perfect for a calendar from another booking tool, a payment button from a provider, a podcast player, a survey or a mortgage calculator. If you want the content to be part of your page for SEO, rebuild it with native Wix elements or CMS content instead.
Not sure which method your snippet needs? Our Wix developers can add and test it for you, usually in a single short session.
Adding tracking codes and pixels
For common marketing tools, Wix provides Marketing Integrations in the dashboard. You enter an ID (such as a GA4 measurement ID or a Tag Manager container ID) rather than pasting code, and Wix places the tag correctly and sends standard eCommerce and booking events where supported. This is more reliable than manual code and avoids double counting.
Our step-by-step guide to connecting Google Analytics 4 and Google Tag Manager to Wix walks through this in detail. If a tool is not listed in Marketing Integrations, add its script with Custom Code, or add it inside Google Tag Manager once that is connected, which keeps all your tags in one place.
Site verification for Google Search Console and other services is often done with a meta tag. Wix has dedicated verification fields in the SEO settings, which is cleaner than a head script. See our Wix SEO setup checklist for the full setup.
Velo, custom elements and custom CSS
When you need code that interacts with your Wix design or data, such as showing a message when a field is filled in, calculating a price, or filtering a list, Velo is the right tool. Velo code can read and change elements, call Wix APIs, query your CMS collections and call external services from the backend.
For advanced interfaces, Velo also supports custom elements: web components you write in JavaScript that render directly on the page rather than in an iframe. In Wix Studio, you can also add custom CSS through a global stylesheet to fine-tune styling beyond the design panels. These options are powerful but need care, because they can conflict with responsive layouts if done carelessly.
Why is my custom code not working on Wix?
When code fails, work through these causes in order:
- Not published or wrong domain. Custom Code usually runs only on the published site with a connected domain.
- Plan requirements. Some custom code features need a premium plan.
- Wrong placement. A script that needs the head will not work in an Embed HTML element.
- Page selection. The code is set to specific pages that do not include the one you are testing.
- Script expects a normal website. Code that looks for specific HTML IDs or modifies the page DOM will not work reliably on Wix, which renders pages its own way. Use Velo instead.
- Cookie consent. If you use a cookie banner, tracking scripts may be blocked until the visitor consents, and Custom Code has a category setting for this.
- Typing errors. Missing closing tags or smart quotes from a word processor break scripts. Copy straight from the vendor.
Common mistakes and a safety checklist
Every script you add is code running on your visitors’ browsers. Treat it with care:
- Adding code from unknown sources. Only use snippets from services you trust and have an account with.
- Loading everything on every page, which slows the site. See our Wix speed optimisation guide.
- Duplicating tracking through both Marketing Integrations and a manual script, inflating your numbers.
- Forgetting old scripts after cancelling a tool. Dead scripts still load and can throw errors.
- Putting secret keys in scripts. Anything in front-end code is public.
Custom code checklist
- Every snippet named with tool and page scope
- Placement and loading options follow the vendor’s instructions
- Scripts limited to the pages that need them
- Consent category set for tracking scripts
- Tested on the live domain on desktop and mobile
- Quarterly review to remove unused code
Need help with custom code? Let MIVAQ do it for you
MIVAQ adds and tests custom code on Wix sites every week: tracking and conversion tags, chat and review widgets, third-party booking and payment embeds, schema markup, Velo features and custom elements. We also audit existing sites to remove duplicate or broken scripts that slow pages down. If your need goes beyond a snippet, we can build a proper feature with Velo or a custom Wix app.
Start with a free consultation; we will confirm the best method and give a fixed-price quote before any work starts. See all our Wix services, or our Wix SEO service if the code is for search or tracking.
- WhatsApp: message us
- Email: hello@mivaq.com
- Form: send your project details
Frequently asked questions
Can I add custom code to Wix on a free plan?
Site-wide Custom Code generally requires a premium plan and a connected domain. The Embed HTML element is more widely available. Check the Wix Help Center for current rules.
Can I edit the HTML of my Wix site directly?
No. Wix does not give access to page source files. You add code through Custom Code, embeds, Marketing Integrations or Velo instead.
Where do I put a script in the head of a Wix site?
In the dashboard Custom Code settings, choose the head placement and select the pages it should load on.
Does embedded HTML help SEO on Wix?
Usually not, because it runs in an iframe. Put important text in native Wix elements so search engines read it as part of your page.
Can MIVAQ add and test custom code on my Wix site?
Yes. We add scripts, embeds and Velo features, test them on the live site and document what was added, for a fixed price agreed upfront.
Related Wix guides
- Velo by Wix: a beginner’s guide to custom code
- Connect Google Analytics 4 and Google Tag Manager to Wix
- Wix integrations with CRM, Zapier and other tools
- Wix security and backups
- Wix website maintenance checklist
- The complete Wix guide
Conclusion
Adding code to Wix is straightforward once you match the code to the right method: Custom Code for site-wide scripts, Embed HTML for contained widgets, Marketing Integrations for tracking, and Velo for anything interactive. Keep it tidy and tested. If you would rather not touch code at all, send MIVAQ the snippet and we will handle it.