Code from an outside service goes into the site through one of two public APIs:
Either way, the code runs on every page, including pages added later, loads according to the visitor's cookie consent, and the owner can turn it off without editing the site. A snippet pasted into page files does none of this: it runs for every visitor whatever their consent, and the owner cannot see it in the dashboard.
Every call below is complete and was run as written: send it without looking up its schema first.
| The user gives | Use |
|---|---|
A tracking ID for Google Analytics (G-…), Google Tag Manager (GTM-…), Google Ads (AW-…), Meta Pixel, TikTok Pixel or Yandex Metrica, on a premium site | Marketing Tags (Step 3a) |
| The same, on a free site | A custom embed with the service's snippet (Step 3b). Marketing Tags answers 428 NOT_A_PREMIUM_SITE on a free site. |
| Any other snippet: a chat widget, a heatmap, a verification meta tag, an ad network | A custom embed (Step 3b) |
Not covered here, because it is not site-wide code from an outside service:
pageFilter is read-only), so it goes in that page.Read both lists before adding anything. When the service is already there, change that entry (Step 4) instead of adding a second copy, which would count every visit twice.
Returns customEmbeds[], each with id, revision, name, enabled, position, embedData.category and embedData.html, and pagingMetadata.hasNext.
Returns tags[], each with id, type (GOOGLE_ANALYTICS, GOOGLE_TAG_MANAGER, GOOGLE_ADS, FACEBOOK_PIXEL, TIKTOK_PIXEL, YANDEX_METRICA, …), enabled, and an object for its type holding trackingId. tags: [] means no marketing integration is connected.
To find a service in custom embeds, search embedData.html for its ID (fbq('init', '<pixel id>'), gtag/js?id=G-…, gtm.js?id=GTM-…).
Adding code changes the live site. A request that hands over the snippet or ID and asks to add or change it is the go-ahead. In any other case, such as tracking the user did not paste, or an entry the user did not mention that the change would replace, tell the user the service, the name the dashboard will show and the consent category from Step 3b, and wait for a yes before Step 3.
Upsert Marketing Tag. The tag holds one object, named for its type: googleAnalytics, googleTagManager, googleAds, facebookPixel, tikTokPixel or yandexMetrica.
domain is required in practice: without it the call answers 400 "domain is not a valid hostname". Use the hostname of the site's primary URL, without https://, from List Published Site URLs (GET https://www.wixapis.com/urls-server/v2/published-site-urls, the entry with primary: true).428 with NOT_A_PREMIUM_SITE. Go to Step 3b with the service's own snippet.Create Custom Embed. Pass the snippet exactly as the service gives it, <script> and <noscript> tags included. A snippet holds both ' and ": put it into the request body as a JSON-encoded string value, not between quotes in code, where its own quotes end the string.
Returns customEmbed.id and customEmbed.revision, which Step 4 needs.
embedData.category decides when the code loads:
| Category | For | Loads |
|---|---|---|
ESSENTIAL | Code the site cannot work without: a verification meta tag, a font, a library the pages call | Always. In the page's HTML as served, except on a static upload, where the browser adds it (Wix Headless sites) |
FUNCTIONAL | Chat widgets, social feeds, review badges | After the page, if the visitor's consent allows it |
ANALYTICS | Google Analytics, Tag Manager, heatmaps, session recording | After the page, if consent allows it |
ADVERTISING | Meta Pixel, TikTok Pixel, Google Ads, ad networks, retargeting | After the page, if consent allows it |
DATA_TO_THIRD_PARTY | Code that sends visitor data to an outside system, such as a CRM | After the page, if consent allows it |
Tracking, analytics and advertising code is never ESSENTIAL: that category loads whatever the visitor chose.
| Field | Values |
|---|---|
position | HEAD, BODY_START or BODY_END. Use the place the service's instructions name; HEAD when they say "in the <head>". |
name | 1-100 characters, shown in the dashboard. Name the service. |
embedData.html | Up to 15,000 characters. For a longer script, embed a <script src="…"> that loads it from the service's own URL. |
loadOnce | Default true: loaded once per visit, not on every page change. |
enabled | Default true. |
The code runs on every page of the site from the next page view.
Update Custom Embed takes the current revision from Step 1 and the fields that change; the fields left out keep their values. embedData is sent whole: an html without its category answers 400 "category value is required". An outdated revision answers 409 INVALID_REVISION; read the embed again and use its revision.
To change the code, such as a new measurement ID, send the full new html with its category:
To turn code off without removing it:
To change a marketing tag's ID, upsert it again (Step 3a). Delete Marketing Tag removes one by type: DELETE https://www.wixapis.com/marketing/v2/tags?tagType=FACEBOOK_PIXEL.
An event tied to the site itself, such as a lead when a form is sent or a call when a phone link is tapped, is a line in the site's own code that calls the function the tag loaded: fbq('track', 'Lead'), or gtag('event', 'conversion', { send_to: '<AW-…/label>' }). Add the tag first (Step 3a or 3b); the event code does not load it.
When consent keeps the tag from loading, fbq and gtag are undefined, so the call checks first:
ESSENTIAL code always loads.ANALYTICS code and not the ADVERTISING code.Custom embeds reach a headless page through the Wix site scripts:
<script id="wix-site-script" …>. A page without that tag runs none of the site's custom code.On a static upload, ESSENTIAL code arrives through the loader as well, so it is not in the HTML the server sends. A check that reads the raw page without running JavaScript, such as a domain verification, does not find a meta tag added this way: put that tag in the page's own <head> instead and upload the page again.
Last updated: 2 December 2026