# Adding Custom Code to a Wix Site

Canonical: https://figment.so/blog/wix-custom-code

In Wix, go to Settings > Custom Code to add an HTML, CSS or JavaScript snippet to a page's head or body. The site must be published with a connected domain, and snippets cannot reach Wix's APIs or data.

**To add custom code in Wix, go to Settings → Custom Code in your site dashboard. The feature injects a raw HTML, CSS or JavaScript snippet into a page's `<head>` or `<body>`, on all pages or specific ones, and it only works once the site is published and has a connected domain.** It runs in every Wix editor, including Harmony, but it cannot touch Wix's own APIs, page elements or data collections. For that you need Velo. The details below come from Wix's developer documentation and help center.

## Where do I find Custom Code, and what does it need first?

Wix's developer documentation says: "You add custom code from the site dashboard under Settings > Custom Code" ([Wix Developers, "About Custom Code"](https://dev.wix.com/docs/develop-websites-sdk/code-your-site/build-a-custom-frontend/custom-code/about-custom-code)). It adds the requirement: "To add custom code, the site must be published and have a connected domain." A site on its default free wixsite.com address, or one that was never published, does not have the option.

## How do I add a snippet?

Wix's Editor walkthrough gives the click path ([Wix, "Wix Editor: Embedding Custom Code on Your Site"](https://support.wix.com/en/article/wix-editor-embedding-custom-code-on-your-site)):

1. Go to **Settings** in your site's dashboard.
2. Click **Custom Code** in the Development & integrations section.
3. Click **+ Add Custom Code** at the top right.
4. Paste your code snippet into the text box.
5. Enter a name for the snippet so you can identify it later.
6. Under **Add Code to Pages**, choose **All pages** (including pages you create later, with the option to load the code once per visit or on every page load) or **Choose specific pages** from a dropdown.
7. Under **Place Code in**, choose **Head**, **Body – start** or **Body – end**.
8. Click **Apply**.

Placement matters: "the placement of your code is crucial for it to load and execute properly." Whoever supplied the snippet should tell you which of the three it needs.

## Does Custom Code work on Wix Studio and Wix Harmony?

Yes. Wix's developer docs say: "Custom code can be used in all Wix editors." Harmony has no site-code layer, so custom code matters more there: "For Wix Harmony sites, which don't support site code, custom code is one of the primary ways to extend a site's functionality beyond what the editor provides." Wix's "About Wix Harmony" page confirms the boundary: "Wix Harmony doesn't support site code. If your projects require code customization, continue using Wix Editor or Wix Studio. However, you can use custom code to add HTML, JavaScript, and CSS snippets to Harmony sites" ([Wix Developers, "About Wix Harmony"](https://dev.wix.com/docs/develop-websites-sdk/code-your-site/build-a-custom-frontend/custom-code/about-custom-code)). Harmony also has a separate Embed element for visible content, covered below.

## What can I use Custom Code for?

Wix's documentation groups the use cases like this:

- **Third-party site verification**, such as the `<meta>` tag Google and Bing require to confirm you own the site.
- **Live chat widgets**, where a support platform gives you a script tag.
- **Cookie consent banners** for GDPR or CCPA-style compliance tools.
- **Custom CSS** beyond the editor's style panel, such as loading a Google Fonts font through a `<link>` tag, overriding spacing or typography on standard HTML tags, or styling browser UI elements like scrollbars.
- **Custom JavaScript**, such as pulling live data from an external API or adding a self-contained widget (a countdown timer or calculator) that doesn't depend on Wix's page elements.
- **Structured data for SEO**, using JSON-LD scripts for schema types like `LocalBusiness`, `FAQPage` or `Event`.

## What can't Custom Code do?

Wix states these limits:

- **No access to Wix's own APIs.** "Custom code can't interact with Wix page elements ($w selectors), data collections, backend methods, or business solutions like Stores, Bookings, or Pricing Plans. It can only work with the raw HTML DOM and external resources."
- **Tracking pixels don't work through it.** "Tracking scripts for Google Analytics, Google Tag Manager, and Facebook & TikTok pixels don't work through custom code. Connect these to a site using marketing integrations instead." For GA4 or a Meta or TikTok pixel, use Marketing Integrations, not Custom Code. Our [GA4 on Wix guide](/blog/wix-google-analytics) shows the steps.
- **No stable selectors.** "Wix generates class names and element IDs dynamically. CSS rules or JavaScript that target these identifiers may break when a site is re-published or updated."
- **No guaranteed DOM compatibility** with Wix's own rendering engine, especially around page transitions or viewport changes.
- **No editor visibility.** Snippets "don't appear as elements in the editor," so a collaborator working visually may not know one exists.
- **No backend execution.** "All custom code runs in the browser." For server-side logic, such as a secure API call, data processing or a scheduled job, Wix points you to the Wix JavaScript SDK on Editor or Studio, which is Velo's territory.

Wix also warns that custom code "is injected directly into the page's HTML and is visible to anyone who views the page source or uses browser developer tools. Don't include API keys, passwords, or other sensitive data in custom code snippets." Keep a secret key in backend code or a proxy, never in a head or body snippet.

## What is the difference between Custom Code and the Embed element?

Custom Code is a site-wide dashboard setting that injects invisible script or style tags. Wix's Editor article says these "snippets are always invisible to your site visitors." The **Embed** element is a visible block on the canvas. In Harmony, add it from **Add Elements → More Options → Embed**, then choose **Embed code** (paste HTML for a widget) or **Embed a site** (show an external HTTPS page inside your page) ([Wix, "Wix Harmony Editor: Embedding a Link or HTML Code"](https://support.wix.com/en/article/wix-harmony-editor-embedding-a-link-or-html-code)). Wix's Custom Code FAQ draws the same line: "How do I embed visible code on my site? Add an iFrame with HTML code to display visual content on your site."

Use Custom Code for invisible head or body scripts that affect the page, and Embed for one visible widget placed like any other element.

## Where does Velo take over?

Where Custom Code's limits stop. Wix says Custom Code and Velo (its site-code layer) "serve different purposes":

| | Custom code | Site code (Velo) |
| --- | --- | --- |
| Purpose | Inject standalone code snippets | Build integrated site functionality |
| Access to Wix APIs | None | Full access to Wix APIs, elements, and data |
| Wix Harmony support | Yes | No |
| Runs on | Browser only | Browser and backend |

If you need to read or write your site's data collections, respond to a Wix event (a completed booking or a new form submission) with custom logic, or call an outside API with a secret key kept hidden, that is Velo, and Velo is not available on Harmony. Our [guide to Velo](/blog/wix-velo) covers frontend page code, backend web modules and database access. If you are unsure which editor your site uses, our [Wix Harmony vs Wix Editor vs Wix Studio guide](/blog/wix-harmony-vs-wix-editor) explains how to check.

## What happens if I change my domain, and how do I check a snippet works?

Wix's FAQ warns: "Your code snippets are associated with a specific domain. If you assign a different domain to your site, your code snippets will be deleted." Save the text of any working snippet outside Wix first, because there is no restore step.

Custom code "doesn't take effect in the editor and only runs on the published site," so the editor preview will not show it. Check the live site with your browser's developer tools (page source, applied styles or console output). For structured data, use Google's Rich Results Test to confirm the JSON-LD is detected and valid.
