> 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: Introduction

## Article: Introduction

## Article Link: https://dev.wix.com/docs/api-reference/app-management/embedded-scripts/introduction.md

## Article Content:

# About the Embedded Script API

You can use the Embedded Script API to inject custom script tags to the head tag of a site.  
If you have custom keys or data, you can use dynamic parameters in your embedded script.  
You can also [listen to predefined Wix events](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/site-extensions/embedded-scripts/analyze-user-behavior-using-embedded-scripts.md#listen-to-predefined-wix-events), and [report and listen to custom events](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/site-extensions/embedded-scripts/analyze-user-behavior-using-embedded-scripts.md#report-and-listen-to-custom-events).

## Using dynamic parameters

The embedded script can include dynamic parameters. For example:

`<script type=“text/javascript” id=“xyz-script-loader” async defer src=“//js.hs-scripts.com/{{abcid}}.js”></script>`


## Before you begin
- You must [authenticate as a Wix App](https://dev.wix.com/docs/rest/articles/getting-started/about-identities.md#wix-app).
- If an app has more than one embedded script component, the relevant component ID must be passed for all calls. The component ID for each embedded script component is available as a query parameter in the embedded script's extension page in the app dashboard.
- If an app only has one embedded script component, don't pass the component ID.
- The keys in the custom parameters passed in this API must be identical to the keys defined in the app's embedded script component. Using any other keys results in a 400 error.
- 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).

## Use cases

- [Listen when a visitor adds an item to a cart](https://dev.wix.com/docs/rest/app-management/embedded-scripts/sample-flows.md).

## 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).

