setPageType

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 to Web experiences and are an alternative to manual URL targeting.

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.

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.

Do not include whitespaces in a page type value.

Refer to the following documentation for recommended page types:

You can use setPageType with the addCategories 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 Example

This screenshot shows the Components tab of the Monetate Inspector browser plug-in. The Page Type row indicates that the value passed by the setPageType method is main.

The Components tab of Monetate Inspector, with main as the Page Type value

Code Samples

// setPageType Method
window.monetateQ.push([
  "setPageType",
  "idString"
]);
// setPageType Example
window.monetateQ = window.monetateQ || [];
window.monetateQ.push([
  "setPageType",
  "main"
]);
window.monetateQ.push([
  "trackData"
]);