---
title: addSearch
slug: js-api/addsearch
description: Overview of the Monetate JavaScript API addSearch method and how to use it for site search and category search in conjunction with the Search and Also Purchased recommendation algorithm
image:  https://archbee-image-uploads.s3.amazonaws.com/ceIfEvQHzQk1IVxoRWUh7/K9eTL4jKm7UQINb6zNziJ-20250912-181225.png
docTags: 
createdAt: 2024-04-30T19:12:37.391Z
---

:::CodeblockTabs
addSearch Method for Site Search

```javascript
// Site Search
window.monetateQ.push([
  "addSearch", {
    "searchTerm": "this is a test",
    "searchType": "site"
  }
]);
window.monetateQ.push([
  "trackData"
]);
```

addSearch Method for Category Search

```javascript
// Category Search 
window.monetateQ.push([
  "addSearch", {
    "searchTerm": "kids",
    "searchType": "category"
  }
]);
window.monetateQ.push([
  "trackData"
]);
```
:::

The [Searched and Also Purchased](https://docs.monetate.com/docs/recommendation-algorithms#searched-and-also-purchased) premium recommendation algorithm requires you to implement one or two `addSearch` method calls to send customers' search query data for use with a [recommendation strategy](https://docs.monetate.com/docs/create-a-recommendation-strategy) configured with this recommendation algorithm. One method call is for site search, and the other is for category search. Implementing both is preferred.

:::hint{type="info"}
In addition to implementing these method calls, you must also contact your dedicated Customer Success Manager (CSM)  to request that the latest script for this recommendation algorithm be pushed to your account so that you can make use of its full capabilities.
:::

You must also implement the `addSearch` method to use the **On-site search terms** WHO Behavior target in experiences. Call the method on all relevant search inputs into which customers provide search terms that you want used for matching with the target's configuration. See [Types of WHO Targets](https://docs.monetate.com/docs/types-of-who-targets#behavior-targets) in the Monetate Knowledge Base for more information about this target.
