> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://adoric.crisp.help/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Add custom JavaScript to your cart

You can add your own JavaScript to your cart. Go to **Cart** tab > **Settings**, then open the **JavaScript** tab in the **Custom code** card.

Custom JavaScript is for advanced changes, like sending an event to your own tracking or changing how a part of the cart behaves. Let's add some.

## Add your JavaScript

1. In your Shopify admin, open **Adoric Cart**, then click your cart in the **Carts** list.
2. At the top of the left panel, click the **Cart** tab.
3. Click **Settings**.
4. In the **Custom code** card, click the **JavaScript** tab.
5. Enter your JavaScript. It applies to the whole cart.

There's no switch to turn it on. If the editor is empty, nothing is added to your cart.

## Know when your script runs

* Your script runs on your live store every time the cart opens.
* It doesn't run in the live preview of the cart editor. That's why you see "Scripts run only on your live store, not in this preview."

||| Wrong JavaScript can stop your script, or parts of your cart, from working as you expect. Test it on your live store after every change.

## Use the code editor

Click the sun or moon icon to switch the code editor between light and dark colors.

To see more of your code, click the expand icon in the code editor. It opens in full screen.

## Get help with code

Not sure what to write? Our team can help you set it up for free. Click **Get support** in the box above the code editor and tell us what you want to do.

## Use JavaScript with A/B tests

Each cart, and each A/B test variant, has its own JavaScript. If you run an A/B test, add the script to every variant that needs it.

## Check the result

1. Click **Save** in the top bar.
2. Turn on the **Cart status** switch in the top bar, so the cart shows **Active**.
3. Open your store, add a product, and open the cart. Check that your script works.

## Related articles

* Add custom CSS to your cart
* Add custom HTML to your cart
* My cart changes are not showing in my store
* Get help from the Adoric team

Still need help? Get help from the Adoric team