addCategories

The addBreadcrumbs method and the addCategories method have similar functionality, and you can use them interchangeably.

The addCategories method is an array of strings that allows you to add identifiers to a trackData call. These strings have no connection to products or items, and they don't necessarily represent groupings of products or services from a catalog. However, you can use this method to indicate that a site visitor is currently on a page that's displaying products from a certain category.

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 example in this documentation demonstrates this use.

If the badge names are listed in order of status—in the addCategories example, Albatross is the highest rank—then you could use an action condition 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 for more information about the options in the Page type action condition category.

Monetate Inspector Example

This screenshot shows the Components tab of the Monetate Inspector browser plug-in. The Categories row indicates that the values passed by the addCategories method are 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

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 Page Categories 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 on cookie value or HTML element.

Code Samples

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