---
title: setPageType
slug: js-api/setpagetype
description: Overview of the Monetate JavaScript API setPageType method and how to use it
image:  https://archbee-image-uploads.s3.amazonaws.com/ceIfEvQHzQk1IVxoRWUh7/K9eTL4jKm7UQINb6zNziJ-20250912-181225.png
docTags: 
createdAt: 2024-04-29T14:42:09.216Z
---

:::CodeblockTabs
setPageType Method

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

The `setPageType` method sends to Monetate the page type for a page that a site visitor is viewing. This information allows you to limit actions to specific page types when you add [action conditions](https://docs.monetate.com/docs/action-conditions) to Web experiences and are an alternative to manual URL targeting.

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

For example, if you want to display a hero banner only on your site's home page, then you must consider all of the following URLs:

- http\://example.com
- http\://example.com/
- https\://example.com
- https\://example.com/
- http\://www\.example.com
- http\://www\.example.com/
- https\://www\.example.com
- https\://www\.example.com/

By defining a page type rather than using a target for all of the possible URLs, you can reliably target visitors with `pagetype=main`.

:::hint{type="info"}
You can pass any string value for page type, but Monetate recommends using a single lowercase word as the value because the values are then easier to remember.
:::

:::hint{type="warning"}
Do not include whitespaces in a page type value.
:::

Refer to the following sections in [Baseline API Call Matrix](docId\:Jt7O1LQ8aUTjhFOLknLnV) for recommended page types:

- [Home Page](docId\:Jt7O1LQ8aUTjhFOLknLnV)
- [Product Detail Page](docId\:Jt7O1LQ8aUTjhFOLknLnV)
- [Cart Page](docId\:Jt7O1LQ8aUTjhFOLknLnV)
- [Checkout Page](docId\:Jt7O1LQ8aUTjhFOLknLnV)
- [Purchase Confirmation Page](docId\:Jt7O1LQ8aUTjhFOLknLnV)

You can use `setPageType` with the [addCategories](docId\:L1mhr-G5A0rK8Zc3l-_ur) method. This approach may be useful if you want to target site visitors viewing the Shirts category on a product listing page with a special offer.

## 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 Page Type row indicates that the `setPageType` method is passing the value `main`.

![The Components tab of Monetate Inspector, with main as the Page Type value](https://dyzz9obi78pm5.cloudfront.net/app/image/id/64f76ba1a48cb90381735954/n/monetate-inspector-components-tab-event-viewpage-page-type-main.png)

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

:::CodeblockTabs
setPageType Example

```javascript
// setPageType Example
window.monetateQ = window.monetateQ || [];
window.monetateQ.push([
  "setPageType",
  "main"
]);
window.monetateQ.push([
  "trackData"
]);
```
:::

