Baseline Implementation

Baseline API Call Matrix

The calls that you implement during a baseline Monetate JavaScript API implementation are just the recommended API calls. You can implement more calls to customize your implementation to meet your business needs.

Required for All Pages

You must include the following for all page types when implementing the Monetate JavaScript API.

monetateQ



trackData

This method sends the information from the monetateQ array to Monetate. Call trackData after all information has been stored in the array. You can call trackData again if any changes are made to the page after the page loads.

Place it at the bottom of the page after all other content has been loaded and relevant information has been added to monetateQ.

When you call trackData more than once because major elements or content on the site has changed (for example, on a single-page application), you must resend all the data to Monetate, including the page type.

AJAX Retracking

If new information or products appear on a page without a new page load, you must retrack, or send a new trackData request, so that the Monetate platform can re-evaluate the page. See Page Retracks for more information.

String Validation

All data that you pass to Monetate through the methods included in this API must be in the form of a string. Passing an integer instead of a string or omitting quotation marks around a string ("string") results in an error.

All strings passed to Monetate need to be in a valid format. These strings are listed below. The API references the following types:

  • string is a JavaScript typeof string that cannot be empty.
  • idString is a string without spaces.
  • pidString is an idString with no more than 50 characters.
  • quantityString is an idString composed only of numerals. The number must be greater than zero and less than one billion.
  • priceString is an idString made up of any number of numerals followed by an optional period and by one or two optional numerals.
  • currencyString is an idString that must adhere to the ISO 4217 format of three capital letters and no spaces.

Variable Field Length

Certain properties available for each method call have a maximum field length. Any field with a maximum length is listed in this table.

Attribute

Data Type

Maximum

Example

purchase_id

VARCHAR

50

"123456789"

sku

VARCHAR

50

"123456789"

pid

VARCHAR

50

"123456789"

quantity

INT

11

"123456789101"

unit_price

DECIMAL

9,2

"900999500.00"

currency

VARCHAR

3

"$"

trackEvent

VARCHAR

32

"50140"

Duplicate purchase_id entries are removed. Each entry's purchase_id must be unique. Furthermore, subsequent purchase_id entries don't need to be incremental.

Product IDs and SKUs in Method Calls

Although both product IDs (PIDs) and SKUs are required in a product catalog, you're only required to implement method calls for PIDs. However, including SKUs enhances the capabilities of both Product Recommendations and product-badging actions.

When choosing a PID to send back to Monetate, use one that is available across all pages when a product is viewed.

Baseline API Calls

Sometimes called the landing page, the home page is the main page on your site. It's usually the first page where site visitors see when they arrive.

Method Calls

setPageType

Recommended Page Type

main

Code Sample

Main Page Example


An index page lists multiple products in a grid or listing for customers to browse. The products on this type of page are not the result of a search performed by a visitor.

Search pages and index pages use the code format contained in this documentation since they normally follow the same page template for your site. Ensure that you use a different page type for each so that if, for example, you want an action to target index pages but not search pages, you can easily do so with Page Type= action conditions.

Method Calls

Recommended Page Type

index

Code Example

Index Page Example


A search page lists multiple products in a grid or listing that are the result of a search the site visitor performed.

Search pages and index pages use the code format contained in this documentation since they normally follow the same page template for your site. Ensure that you use a different page type for each so that if, for example, you want an action to target index pages but not search pages, you can easily do so with Page Type= action conditions.

Method Calls

Recommended Page Type

search

Code Example

Search Page Example


A product detail page, sometimes called simply a product page, contains such key information as available sizes, colors, models, or other variations of a specific product.

Method Calls

Recommended Page Type

product

Code Example

Product Detail Page Example


The cart page is any page on your site on which the visitor sees what products are in their cart.

If cart data is available on all pages, Monetate recommends including the addCartRows method to all pages and not just your "cart" page.

Method Calls

Recommended Page Type

cart

Code Example

Cart Page Example


The checkout page shows registered users a summary of their order details.

Method Calls

setPageType

Recommended Page Type

checkout

Checkout Page Example


The purchase confirmation page loads after a customer has completed a transaction.

Method Calls

Recommended Page Type

purchase

Code Example

Purchase Page Example