Skip to main content

Send a trigger to customers who have viewed or carted a particular category

Use filters on your Trigger Program.

Updated over 2 weeks ago

Use filters on your Trigger Program to send a trigger only if a customer has a product from a specified category in their cart. This guide explains how to set up these filters using category IDs.

Find category IDs

  1. Go to Reports > All Reports.

  2. Expand the System Data drop-down menu and select Currencies, Tags, Site Brands and Languages.

  3. Select the Tags tab.

Example code filter

The following code filter sends the trigger if the customer has a product from one of the specified categories in their cart:

var cats_to_match = ['example1', 'example-cat', 'example-cat-id'];

result.proceed = false;

if (helpers.productsInCategories(helpers.getProducts(), cats_to_match) > 0) {

result.proceed = true;

}

Alternative method

Here is an alternative method to achieve the same result:

var matchingCats = ['cat-id-1','cat-id-2','catID'];

result.proceed = false;

if (helpers.getProducts() && helpers.getProducts().length) {

for (var i = 0; i < helpers.getProducts().length; i++) {

var product = helpers.getProducts()[i];

if (product.cat) {

for (var c = 0; c < product.cat.length; c++) {

if (matchingCats.indexOf(product.cat[c].catid) !== -1){

result.proceed = true;

break;

}

}

}

}

}

Verify category collection

Ensure that categories are being collected by checking the Categories report or viewing the product details in the Products report.

Did this answer your question?