Add a cookie banner to your Wix site with "Custom Code"
Add the TermsFeed Free Cookie Consent code to every page through Custom Code, tag the scripts you add there, and decide on the Wix cookie banner. Cookie Consent holds only the tagged scripts you add in Custom Code. Wix adds its own analytics, its session cookies, and the trackers you connect in Marketing Integrations, and Cookie Consent controls none of them.
Wix runs Google Analytics, Google Tag Manager, the Meta Pixel, and the TikTok Pixel only through Marketing Integrations. Its Custom Code help page says these tracking scripts "do not work through custom code".
Setup takes 3 steps and about 20 minutes. Custom Code needs a published site with a connected domain, and a connected domain needs a Premium plan (a Studio plan for a site built in Wix Studio). Generate your code at termsfeed.com/cookie-consent with the generator defaults, which use express consent.
Step 1: Add the Cookie Consent code in "Custom Code"
Add the code as a Custom Code entry on all pages, placed at the end of the body and loaded once per visit. A Custom Code entry runs on the live site with your connected domain, not in the Editor preview. Wix gives every new entry the code type Essential, which it loads before any consent, and Cookie Consent needs that type to show its consent banner at once.
Create the entry in the site dashboard.
- Open Settings in your site dashboard.
- Open Custom Code in the Development & integrations section.
- Click + Add Custom Code at the top right.
- Paste the Cookie Consent code into the text box and name the entry "Cookie Consent".
- Select All pages under Add Code to Pages, and choose to load the code once per visit.
- Select Body - end under Place Code in.
- Keep Essential on the Code Type tab and click Apply.
Keep the options you chose in the generator and the "Update cookies preferences" link at the end, as in this generator example. The example script address starts with https:, while the generator writes it without, and both forms load the same file.
<!-- Cookie Consent by TermsFeed https://www.TermsFeed.com -->
<script type="text/javascript" src="https://www.termsfeed.com/public/cookie-consent/4.2.0/cookie-consent.js" charset="UTF-8"></script>
<script type="text/javascript" charset="UTF-8">
document.addEventListener('DOMContentLoaded', function () {
cookieconsent.run({"notice_banner_type":"headline","consent_type":"express","palette":"dark","language":"en","page_load_consent_levels":["strictly-necessary"],"notice_banner_reject_button_hide":false,"preferences_center_close_button_hide":false,"page_refresh_confirmation_buttons":false,"website_name":"Example Store"});
});
</script>
<noscript>Free cookie consent management tool by <a href="https://www.termsfeed.com/">TermsFeed Generator</a></noscript>
<!-- End Cookie Consent by TermsFeed https://www.TermsFeed.com -->
<a href="#" id="open_preferences_center">Update cookies preferences</a>
Wix returns an Essential entry in the page HTML at once, according to the Wix Custom Embeds API. An entry set to load once loads only when the site first renders, and its run() call starts once the HTML of that first page has loaded. An entry that loads on each new page adds the script again on every page change, and that second copy does nothing. Read about each part of the code in Install a Cookie Banner on Any Website.
Step 2: Tag the scripts you add in "Custom Code"
Tag each optional script that stores data in the browser or sends data to another company with its category. Add each one as its own Custom Code entry. Cookie Consent reads the tagged scripts once, when run() starts, and, in express mode, runs each optional one after the visitor accepts its category.
Use Custom Code only for tools whose own install guide supports it, such as HubSpot, whose tracking code guide has a Wix section. Replace HUB_ID with your HubSpot account ID in this HubSpot tracking code, tagged with tracking.
<script type="text/plain" data-cookie-consent="tracking" id="hs-script-loader" async defer src="https://js.hs-scripts.com/HUB_ID.js"></script>
Keep each tagged entry on All pages, Body - end, loaded once, and Essential, so the tagged script is in the page when run() starts. HubSpot asks for an entry that loads on each new page, which this setup does not use. With the entry loaded once, HubSpot records only the first page of each visit, because it counts a page view only when its code loads. Turn off the HubSpot consent banner and copy the other HubSpot steps from Block HubSpot Tracking Until Consent.
Step 3: Decide what to do with the Wix consent banner
Choose between 2 consent banners on every page, or a single Cookie Consent banner with Wix tools following the default consent policy of the site. The Wix consent banner asks each visitor for consent to Wix Analytics, the trackers you connect in Marketing Integrations, and some apps. Wix does not give a guarantee that its consent banner blocks cookies from App Market apps or from elements outside its control.
Wix offers its consent banner through Usercentrics, from Privacy & Cookies in the dashboard. Its settings have a "Show banner" toggle, according to the Wix help page on cookie consent.
Keep the Wix consent banner on when you use Wix Analytics or Marketing Integrations. Visitors then answer 2 consent banners, one for Wix tools and one for your Custom Code. To show visitors a single consent banner instead, turn the Wix consent banner off with the "Show banner" toggle. Wix tools then run under the default consent policy of the site, which allows every cookie type unless a consent app changes it.
Keep the Code Type of the Cookie Consent entry on Essential in both cases, so Cookie Consent never depends on the Wix consent policy. While the Wix consent banner is on, Wix loads an entry of another type only once the visitor accepts that type in the Wix consent banner. A Cookie Consent entry of another type shows nothing until then. Find how to tell the 2 consent banners apart in 2 Cookie Banners Appear on Your Site.
Add a preferences link to your Wix site
Keep the "Update cookies preferences" link at the end of the Cookie Consent entry, so visitors reopen the Preferences Center from every page. Wix places a Body - end entry at the end of the <body> element, after your site content. The link therefore appears below the content on every page.
The link works through its id, open_preferences_center, and once Cookie Consent runs, it stops the browser from following the link. Change the text of the link, but keep the id. Choose another way to open the Preferences Center from Add a Cookie Settings Link.
How to verify Cookie Consent on your Wix site
The checks assume express consent with page_load_consent_levels left out or at the generator value ["strictly-necessary"], and the "I decline" button shown. Check the published site on its connected domain. A new private window starts with no saved answer once every other private window is closed, so the consent banner shows as it does for a new visitor.
Run the checks in order, and filter on the host of your tagged tool.
- Close every private window, open your site on its connected domain in a new one, open Chrome DevTools, select the Network tab, type
cookie-consentin the filter box, and reload. The loadercookie-consent.js, the scriptcookie-consent-code.js, and the ping appear, and the consent banner shows. - Type the host of your tagged tool in the filter box, such as
hs-scripts, and reload. No request appears before you answer. - Click the "I agree" button. A request to that host, such as
js.hs-scripts.com, appears without a page reload. - Select the Application tab, open Cookies for your domain, and check that
cookie_consent_levelandcookie_consent_user_acceptedexist. - Click the "Update cookies preferences" link at the bottom of the page. The Preferences Center opens.
Close every private window and open a new one. Open DevTools with the Network tab filtered on the host of your tagged tool, load your site, and click the "I decline" button. Open a second page and confirm that the Network tab does not list any request to the host of your tagged tool. Run every other check from Check That Your Cookie Banner Works.
Common mistakes with Cookie Consent on Wix
Open each Custom Code entry first, because its load setting and its code type decide whether a tagged script runs.
- An entry loads on each new page. A tagged script that Wix adds on a page change never runs. Read the load setting of each entry in Settings > Custom Code, and set every entry to load once.
- An entry has a code type other than Essential. While the Wix consent banner is on, the Cookie Consent banner waits until the visitor accepts that code type there, and a tagged script that arrives after
run()never runs. The Code Type tab of the entry shows the type it has. Set the entry back to Essential. - Google Analytics, Google Tag Manager, the Meta Pixel, or the TikTok Pixel sits in Custom Code. The Custom Code list shows an entry for one of these tools. Connect them in Marketing Integrations, where the Wix consent banner controls them while it is on.
- You test in the Editor preview. The Network tab of the preview does not show a
cookie-consent.jsrequest. Test the published site on your connected domain. - The tagged script sits in an iframe. An Embed HTML element runs its code in an iframe, which Cookie Consent never reads, and the Elements tab shows the script inside an
<iframe>. Put every tagged script in Custom Code.
Wix sets its session cookies on every visit, whatever the visitor answers. Check the full list of Cookie Consent limits in Limits of Free Cookie Consent: What It Does Not Do.