---
title: addCategories
slug: js-api/addcategories
description: Overview of the Monetate JavaScript API addCategories method and how to use it
image:  https://archbee-image-uploads.s3.amazonaws.com/ceIfEvQHzQk1IVxoRWUh7/K9eTL4jKm7UQINb6zNziJ-20250912-181225.png
docTags: 
createdAt: 2024-04-29T15:11:40.494Z
---

:::CodeblockTabs
addCategories Method

```javascript
// addCategories Method
window.monetateQ.push([
  "addCategories", ["string", "string", "string"]
]);
```
:::

The `addCategories` method is an array of strings that allows you to add identifiers to a [trackData](docId\:gcm0H169GurCQMv6sBota) call. These strings have no connection to products or items, and they don't necessarily represent groupings of products or services from a catalog.

:::hint{type="info"}
You can use the `addCategories` method on all page types of your site.
:::

You can also use this method to indicate that a site visitor is currently on a page that's displaying products from a certain category.

:::hint{type="info"}
The `addBreadcrumbs` [method](docId\:pVve37Ya7ozKDXKSn-IeS) and the `addCategories` method have similar functionality, and you can use them interchangeably.
:::

For example, your site may have a rewards program that allows customers to earn badges. A customer has all the badges they've earned displayed on the page. You can store these values in a single string and pass them to `addCategories`. The `addCategories` code example in this documentation demonstrates this use.

If the badge names are listed in order of status—in the `addCategories` code example, Albatross is the highest rank—then you could use an [action condition](https://docs.monetate.com/docs/action-conditions) to target customers whose highest badge is Swan by using the **Page category ends with: swan** action condition or target customers who have Pelican status or higher with the **Page category contains: pelican** action condition.

See [Action Conditions](https://docs.monetate.com/docs/action-conditions) in the Monetate Knowledge Base for more information about the options in the **Page type** action condition category.

### Targeting JavaScript Variables and Other Types at the Action Level

If you prefer to target JavaScript variables at the action level rather than the experience level, you can use an option from the **Page category** action condition category and the `addCategories` method call. You can use page Categories based on any data on your page, not just product categories. Similarly, you can use page categories to also target a cookie value or HTML element.

## Monetate Inspector View

This screenshot shows the **Components** tab of the [Monetate Inspector browser plug-in](https://docs.monetate.com/docs/install-the-monetate-inspector-browser-plug-in). The Categories row indicates that the `addCategories` method passed the values of the example badges listed in status order.

![The Components tab of Monetate Inspector, with viewPage in the Event row, unknown in the Page Type row, and the Penguin, Pelican, Swan, and Albatross badge values in the Categories row](https://dyzz9obi78pm5.cloudfront.net/app/image/id/64f7709ecf4b41570755cff4/n/monetate-inspector-components-tab-event-viewpage-page-type-unknown-categories-membership-levels.png)

This code example contains the method in use that results in the Monetate Inspector results shown in the previous screenshot.

:::CodeblockTabs
addCategories Example

```javascript
// addCategories Example
window.monetateQ = window.monetateQ || [];
window.monetateQ.push([
  "addCategories", ["penguin", "pelican", "swan", "albatross"]
]);
window.monetateQ.push([
  "trackData"
]);
```
:::

