> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: About Embedded Scripts

## Article: About Embedded Scripts

## Article Link: https://dev.wix.com/docs/build-apps/develop-your-app/extensions/site-extensions/embedded-scripts/about-embedded-scripts.md

## Article Content:

# About Embedded Scripts

An embedded script is an app extension that injects an HTML code fragment into the DOM of a site. Unlike other extensions, embedded scripts aren't fully configured by default during app installation and an extra step is required to embed the code fragment. For detailed instructions, see:

* [Add a Self-Managed Embedded Script Extension](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/self-hosting/supported-extensions/site-extensions/embedded-scripts/add-an-embedded-script-extension-to-a-self-hosted-app.md)
* [Add an Embedded Script Extension Using the Wix CLI](https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/supported-extensions/site/embedded-scripts/add-an-embedded-script-extension-with-the-wix-cli.md)

## Example use cases

Embedded scripts have a variety of uses, including:

* **Analytics**: Use embedded scripts to listen to predefined Wix events as well as report and listen to custom events. Examples of predefined Wix events include clicking on a product or adding an item to a cart. For more information, see [Analyze User Behavior Using Embedded Scripts](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/site-extensions/embedded-scripts/analyze-user-behavior-using-embedded-scripts.md).
* **Site Interaction**: Access site data and integrate with apps made by Wix, such as Wix Stores and Wix Bookings, using the [Site API](https://dev.wix.com/docs/sdk/host-modules/site/introduction.md). The Site API is only available for embedded scripts created with the [CLI](https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/supported-extensions/site/embedded-scripts/add-an-embedded-script-extension-with-the-wix-cli.md).
* **Customized Behavior**: Enhance user engagement by adding dynamic features like pop-ups, sliders, or tooltips that react to user inputs.

## Embedded script types

Script types determine whether site visitors consent to having your script run during their visit.
Script types categorize embedded scripts for privacy and consent management purposes according to GDPR and similar data protection guidelines. 
For more information about meeting consent requirements and selecting a script type, see [Implement Cookie Consent Requirements](https://dev.wix.com/docs/build-apps/launch-your-app/legal-and-security/gdpr-compliance/implement-cookie-consent-requirements.md#implement-cookie-consent-requirements).

Each embedded script must specify 1 of the following types:

| Type          | Description                                      | Use Cases                               |
| ------------- | ------------------------------------------------ | --------------------------------------- |
| `ESSENTIAL`   | Core functionality crucial to site operation.     | Authentication, security features       |
| `FUNCTIONAL`  | Remembers site visitors' choices to improve experience.     | Language preferences, UI customization  |
| `ANALYTICS`   | Provides statistics on how visitors use the site. | Google Analytics, Hotjar, Mixpanel      |
| `ADVERTISING` | Provides visitor data for marketing purposes.     | Facebook Pixel, Google Ads, retargeting |

<blockquote class="important">
  <strong>Important:</strong>
  
  If a script falls into multiple types, choose the option closest to the bottom of the list (most restrictive). For example, a script with both **Analytics** and **Advertising** aspects should use `ADVERTISING`.
</blockquote>

## Dynamic parameters

If you have custom keys or data per user, you can use dynamic parameters in your embedded script. 

Dynamic parameters must:

* Be strings.
* Contain only alphanumeric characters (no special characters or spaces).
* Be wrapped in double curly braces (`{{`).
* Be enclosed in quotes (`"`) to prevent code evaluation.
* Be provided upon installation when calling [Embed Script](https://dev.wix.com/docs/rest/app-management/embedded-scripts/embed-script.md).

For example:

```javascript
<script id="my-script" src="https://cdn.example.com/pixel.js?id={{KeyName123}}" async='true'></script>
```

<blockquote class="important">

**Important:** If you add, remove, or change a dynamic parameter, users must update your app to receive the latest version of the embedded script.

</blockquote>

## Troubleshooting

The `MISMATCHED ANONYMOUS DEFINE() MODULES...` error is a common issue when working with AMD/UMD bundled scripts. The error occurs when an embedded script defines an anonymous module, either because it's bundled with AMD or it adds a script tag to the head containing an anonymous module.

To resolve the issue, try the following:

* **For the embedded script itself:** If the script is bundled with AMD/UMD, make sure that you declare only [named modules](https://requirejs.org/docs/api.html#modulename).
* **For scripts loaded by the embed**:
  * **If you own the code:** If the scripts are bundled with AMD/UMD, make sure that you declare only [named modules](https://requirejs.org/docs/api.html#modulename).
  * **If you don't own the code:** Check if `requirejs` exists on the window. If it does, load the script via `requirejs` instead of adding the script to the `<head>`. This approach is suboptimal and might still lead to race conditions and errors.

For more information on this issue, see [RequireJS: Common Errors](https://requirejs.org/docs/errors.html#mismatch).

## See also

* [Analyze User Behavior Using Embedded Scripts](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/site-extensions/embedded-scripts/analyze-user-behavior-using-embedded-scripts.md)
* [Customize Wix Stores Using Embedded Scripts](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/site-extensions/embedded-scripts/customize-wix-stores-using-embedded-scripts.md)
* [Add a Self-Managed Embedded Script Extension](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/self-hosting/supported-extensions/site-extensions/embedded-scripts/add-an-embedded-script-extension-to-a-self-hosted-app.md)
* [Add an Embedded Script Extension Using the Wix CLI](https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/supported-extensions/site/embedded-scripts/add-an-embedded-script-extension-with-the-wix-cli.md)