> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cometly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Set up Add to Cart and Initiate Checkout events

> Track Add to Cart and Initiate Checkout events with Google Tag Manager so Cometly shows which ads bring shoppers who add to cart and start checkout.

**Add to Cart**, **Initiate Checkout** and **View Content** are events: actions a visitor takes on your store that Cometly records. The Cometly pixel (the tracking script on your site) captures general visitor activity on its own, but you set each of these events up yourself, however the pixel was installed. This guide shows you how to track Add to Cart and Initiate Checkout events with Google Tag Manager (GTM).

Once the events fire, you can see which ads bring shoppers who add a product to their cart or start checkout, not only the ones who buy. That shows you where shoppers drop off between the ad click and the purchase.

## Before you start

* You need a Google Tag Manager web container on your store. If you do not have one yet, [set up a new GTM web container](https://docs.cometly.com/support/troubleshooting/pixel/google-tag-manager-web-container.md) first.
* The Cometly pixel must load on every page of your store.

> [!WARNING]
>
> If the Cometly pixel is already on your store (hard-coded in the `<head>` or installed by the Cometly WooCommerce plugin), do not install it again through Google Tag Manager. Skip to [Set up the events in Google Tag Manager](#set-up-the-events-in-google-tag-manager).

## Add the Cometly pixel in Google Tag Manager

Only do this if the pixel is not on your store yet.

1. In Cometly, go to **Setup**, open the step **Install the Cometly pixel**, and click **Copy Code** under **Install the pixel**. See [Install the Cometly pixel](https://docs.cometly.com/getting-started/install-pixel.md) for details.
2. In your GTM workspace, add a new tag and name it `Cometly Pixel`.
3. Click **Tag Configuration** and choose a **Custom HTML** tag.
4. Paste your Cometly pixel into the HTML box.
5. Set the trigger to **All Pages**.

## Set up the events in Google Tag Manager

The video walks through the full setup in Google Tag Manager.

> [!NOTE]
>
> The video mentions a second tag called `init`. That tag has been deprecated, so ignore every reference to it. The only pixel tag you need in Google Tag Manager is the Cometly pixel, and only when the pixel is not already on your site.

[Set up Add to Cart and Initiate Checkout events in Google Tag Manager](https://www.loom.com/embed/64619fdc6ef54b3e945fad7918d61a4b)

The steps shown in the video:

1. Configure the built-in variables.
2. Create an **All Clicks** trigger.
3. Use GTM preview mode to see the Click Text and Click Classes of each click on your store.
4. Add the tag `Cometly - Add To Cart`.
5. Add the tag `Cometly - Initiate Checkout`.
6. Add the tag `Cometly - View Content`.

### Event code

Each tag is a Custom HTML tag that holds one of these snippets.

**Add to Cart**

```html theme={null}
<script>
	comet('add_to_cart');
</script>
```

**Initiate Checkout**

```html theme={null}
<script>
	comet('initiate_checkout');
</script>
```

**View Content**

```html theme={null}
<script>
	comet('view_content');
</script>
```

## Pre-purchase upsell apps: set up the Add to Cart trigger

If your store uses a pre-purchase upsell app, this video shows how to set up the Add to Cart trigger for it.

[Set up the Add to Cart trigger for pre-purchase upsell apps](https://www.loom.com/embed/10fb5a295d604456b66237d7f58a2bcf)

## Check it worked

Open your store with GTM preview mode on, add a product to your cart and start checkout, and confirm that each Cometly tag fires. Then, in Cometly, go to **Events Manager**, open the **Events Log** tab and set **Source** to **Browser**: the events you triggered are listed there. You can also test them on your store with the [Cometly Pixel Helper](https://docs.cometly.com/guides/tracking/pixel-helper.md).

## Frequently asked questions

### Do I need Google Tag Manager to track Add to Cart and Initiate Checkout events on WooCommerce?

Not if you use the Cometly WooCommerce plugin. The plugin fires the Add to Cart and Initiate Checkout events for you, along with the Purchase event. See the [WooCommerce integration](https://docs.cometly.com/integrations/platforms/woocommerce.md).

### Does the Cometly pixel have to be in Google Tag Manager for these events to fire?

No. The events fire properly when the pixel is hard-coded on your store. Only add the pixel through Google Tag Manager if it is not on your store yet, so it is never installed twice.

### Where do I see Add to Cart and Initiate Checkout in my Cometly reports?

Both are standard events, and each has its own metric: **Add to Cart** counts add to cart actions and **Initiate Checkout** counts checkout initiations. See the [metrics glossary](https://docs.cometly.com/guides/analyzing-data/metrics-glossary.md) for the full list.

## Next steps

* [Check incoming events in the Events Log](https://docs.cometly.com/support/troubleshooting/general/event-log.md)
* [Test your events with the Cometly Pixel Helper](https://docs.cometly.com/guides/tracking/pixel-helper.md)
* [Learn how standard and custom events work](https://docs.cometly.com/guides/events/how-events-work.md)
* [Connect your Shopify store](https://docs.cometly.com/integrations/platforms/shopify.md)
* [Send events to ad platforms with the Conversion API](https://docs.cometly.com/guides/conversion-api/overview.md)

Still have questions or need a hand? We're happy to help. Reach our team at [support@cometly.com](mailto:support@cometly.com).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.