How to add analytics to a Wix site with custom code
The tag goes in Settings under Custom Code, which needs a connected domain and so an upgraded plan. Two settings then decide what it counts: whether it loads once or on every page, and which code type Wix's cookie banner sees.
In this article
A Wix site has no HTML file to paste a script into. Analytics goes in through Custom Code, a page in the site's dashboard, and two of its settings affect what gets counted: whether the code loads once per visit or on every page, and which cookie category it's filed under. Before either, check that your plan allows custom code at all, and what Wix already counts for you.
The steps work for any analytics tool that installs with a script tag. The Wix details come from its help center and developer docs, as of November 2026.
Check your plan first
Wix's help page on embedding custom code names two conditions before you start: the site is published, and it has a connected domain. Connecting a domain needs an upgraded site. Wix's page on assigning domains says a site without a Premium or Studio site plan has to be upgraded first, or take over a plan you already have. A site that only lives at its free address, in the form siteprefix.wixsite.com/site-name, doesn't get custom code.
According to Wix's developer docs, the same Custom Code page is used on Wix Editor and Wix Studio sites. Some tags don't belong there at all: Wix says Google Analytics, Google Tag Manager and the Facebook and TikTok pixels don't work through custom code, and go in through Marketing Integrations instead.
What Wix already counts
Before you add a tool, look at what the dashboard already shows. Wix has several pieces, and most of them depend on the plan:
Wix Analytics
The Traffic Overview, under Analytics in the dashboard, shows sessions, unique visitors, sources with their category (social, email, organic search), new against returning visitors, devices and countries. Wix ends a session after 30 minutes of inactivity and counts a unique visitor by device and browser. Visitors who haven't accepted the site's cookies don't appear in these reports.
Analytics Pro
An AI assistant that works with the same data. You ask in your own words and get an answer with a chart. Wix's reports page says it needs an upgraded site.
AI Visibility Overview
Shows how often ChatGPT, Gemini and Perplexity mention the site, the sessions that came from each, and when their bots last crawled it. According to Wix, it needs a Premium plan and at least 50 unique visitors in the last 30 days, and each new test uses AI credits.
Google Analytics, through Google Tag
You add your GA4 measurement ID under Marketing Integrations, with Connect under Google Tag. Wix's instructions list a Premium site and a connected domain, and have you untick GA4's “Page changes based on browser history events” when you create the stream. With a cookie banner, Google Analytics only collects data after consent.
Add the script in Custom Code
Sign up for the tool you picked, add your site using its primary domain, the address visitors end up on, and copy the snippet it gives you, usually a single <script> tag shaped roughly like this:
<script defer src="https://analytics.example.com/script.js" data-site="YOUR-SITE-ID"></script>That's a placeholder, not a working tag. Copy the exact one from your tool and don't change its attributes. Then, following Wix's help page:
- Go to Settings in your site's dashboard, not in the editor.
- Click Custom Code, in the Development & integrations section, then + Add Custom Code at the top right.
- Paste the tag into the text box and give it a name you'll recognise later, such as the tool's name.
- Under Add Code to Pages, choose All pages. Wix says this includes pages you create later. Choose specific pages leaves every other page uncounted.
- Under Place Code in, choose Head. Wix's own advice is to put tracking and verification code in the head, unless the provider says otherwise.
- Set the loading option and the code type, both covered below, then click Apply.
Wix ties each snippet to a domain. Its help page says that if you assign a different domain to the site, the snippets are deleted, and that a secondary domain doesn't need its own copy, because its traffic is redirected to the primary one. That primary domain is the one to register in your analytics tool.
Load once, or on every page?
With All pages selected, Wix asks how the code loads. This is the setting that decides whether a tool counts one page per visit or all of them, and Wix's article on loading options explains why. Wix sites are built as single-page applications. The browser loads the site once, later pages arrive without a new page load, and each move from page to page is reported through pushState, the browser's way of changing the address without reloading. The two options:
- Load once, the default. The code loads with the first page of the visit. Wix says later pages are only tracked if the code itself supports
pushState, and suggests asking the code's provider. - Reload on every page. The code is loaded again after every page change. Wix notes that this option isn't recommended for tracking pixels.
So the question for your tool's docs is whether its script follows page changes in a single-page app on its own. If it does, Load once is the right choice, and reloading it on every page can make it count pages twice. Rybbit's Wix guide, for example, tells you to switch to Load code once if you see duplicate pageviews. If the tool only counts full page loads, Load once records the first page of each visit and nothing after it. Look for “single-page app”, “SPA”, “pushState” or “client-side navigation” in its docs, and whichever you pick, run the click-through test further down.
On Wix, the browser loads the site once. Every page after that is up to your script to notice.
The code type and the cookie banner
Wix asks one more thing, under the Code Type tab: what the code is for. According to Wix's help page on categorizing custom code, the choices are Essential, Marketing, Analytic and Functional, and every snippet starts as Essential. Essential code is loaded before the visitor gives consent and can't be switched off. If the code is better described by one of the other categories, Wix says classifying it that way is your responsibility.
What a banner then does with the script is less clear-cut. Wix's page on displaying a cookie banner says the banner holds back non-essential cookies and scripts until the visitor consents, but also that Wix can't guarantee it blocks non-essential cookies from custom code. The same page says the original Wix Cookie Banner is no longer available for new sites and offers a Usercentrics banner instead. So treat the code type as a description of what the script does, not a switch for more traffic, and check what your banner actually does with it, as in the test below. A tool that sets analytics cookies fits Analytic, and if the banner holds it back, its numbers only include visitors who said yes. Whether a script that stores nothing on the device needs consent at all is a legal question for your site, not a setting in Wix. What it takes to run a website without a cookie banner goes through the rules.
Test on the published site
Wix's developer docs say custom code doesn't take effect in the editor and only runs on the published site. So test there, on your connected domain:
- Open the site in a private window, with any ad or tracker blocker turned off for the test. If a cookie banner appears, leave it unanswered for now.
- Open the developer tools, go to the Network tab and reload. Filter by your tool's domain. You should see the script load, and usually a second request that sends the pageview. If nothing loads and the site has a banner, accept it and look again. That tells you whether the banner holds the script back until consent.
- Look at the Console tab for errors. Wix's security measures either block an operation silently or throw an error, so an error that mentions the tool's script is worth reading.
- Open the tool's live or real-time view, if it has one, and look for your visit.
- Click through three or four pages using the site's own menu and links, not the address bar, and check that each one shows up as one pageview. This is the step that shows whether the loading option suits your tool.
If the numbers look wrong
- No Custom Code to add. The site isn't published, or it has no connected domain, which needs a Premium or Studio plan.
- Every visit is one page long. The code is set to Load once and the script doesn't follow
pushState. Turn on the tool's single-page app setting, or switch to Reload on every page, and test again. Until then your bounce rate will look far worse than it is. - Every page counted twice. The script follows page changes and is also set to Reload on every page, or the same snippet is in the Custom Code list twice. Switch to Load once, or remove the copy.
- Only some pages show up. The snippet is set to specific pages. Edit it and choose All pages.
- Numbers dropped when the cookie banner went on. The banner is holding the script back until visitors accept, so those who don't aren't counted. Confirm it in the Network tab, before and after accepting, and look at the code type you chose.
- The snippet is gone. The site was given a different domain, and Wix deleted its snippets. Add the code again.
- It used to work and now doesn't. Wix says it introduced new frontend security measures for custom code in December 2025, and that some snippets that used to work may be blocked until their provider updates them. Its frontend security docs list what's restricted. Send them to the tool's support.
- Wix and the tool disagree. They will. With a cookie banner, Wix's reports leave out visitors who haven't consented to analytics cookies, while a script that loads before consent counts them, and each tool has its own rules for sessions and unique visitors. Check that both rise and fall on the same days, and read why no two analytics tools agree on your traffic for where the gaps come from.
A cookie-free script, but is the site?
A cookie-free analytics script means the script sets no cookies. The rest of the site still can. Wix's help page on cookies lists the ones Wix places on its sites, such as XSRF-TOKEN for fraud detection, svSession for security, stability and core site function and SSR-caching for rendering, and marks them as essential. It adds that Wix's business solutions, such as Stores and Bookings, third-party apps and integrations such as Google Analytics can place more.
To see what your published site stores, open it in a private window, browse a few pages and look under Cookies and Local storage in the developer tools. Whether you can do without a banner depends on that whole list, and the cookie-free website guide goes through it.
The short version
- Check that the site is published on a connected domain, which needs an upgraded plan.
- Look at Wix Analytics, Analytics Pro and the AI Visibility Overview first.
- Google Analytics goes in Marketing Integrations, not Custom Code.
- Settings → Custom Code → + Add Custom Code: All pages, Head.
- Load once if the script follows pushState, Reload on every page if it doesn't.
- Pick the code type that describes the script, and check what the banner does with it.
- Test on the live domain by clicking through several pages.
Lomen is one of the tools you could add this way, as one script tag in Wix's Custom Code, with no API key, package or build step. Its script follows pushState page changes on its own, so Load once is the setting for it, and a second copy of the tag for the same site does nothing, so a duplicate in the list can't double the count. Pageviews only count from the domain you added and its subdomains, so add your primary connected domain. It sets no cookies, never stores IP addresses and by default keeps nothing in the visitor's browser. Which code type that calls for on your site is still your decision. It groups visits from nine AI assistants by referrer and utm_source, and Lomen AI, a chat in the dashboard, answers questions about your own figures. It can put revenue from Stripe, Shopify, Lemon Squeezy, Polar or Paystack on the same chart as visitors, but it doesn't connect to Wix, so it only sees sales whose money lands in one of those accounts. It has no custom events or funnels. Lomen is free during the public beta.