Skip to main content
All CollectionsTriggersAdvanced trigger control
Send a trigger to customers who have viewed or carted a particular category
Send a trigger to customers who have viewed or carted a particular category

Use filters on your Trigger Program.

Updated over a year ago

The following code filter sends the Trigger only if the person has a product in one of the categories specified in their cart.

The script uses the category ID rather than the category name.

To see 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.

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;

}

Here's an alternative method:

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;

}

}

}

}

}

You must check that categories are being collected. You can see this by looking at the Categories report, or by viewing the product details on the Products report.

Did this answer your question?