Baseline Implementation

Baseline API Call Matrix

the calls that you implement during a baseline 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 each array in the monetateq array contains instructions to add data that monetate tracks the first index of each array is the method name the most common method is setpagetype , which is required in every monetateq array to indicate the type of page that the customer is viewing all data is sent asynchronously to monetate by calling the trackdata method this method takes no arguments it can be called whenever data is ready to be sent to monetate each time the trackdata method is called, the monetateq array is cleared so that new data can be pushed monetateq example // monetateq example window\ monetateq push(\[ method, data ]); add the monetateq array in the page template directly after the baseline implementation trackdata this trackdata 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 home page 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 // main page example window\ monetateq = window\ monetateq || \[]; window\ monetateq push(\[ "setpagetype", "main" ]); window\ monetateq push(\[ "trackdata" ]); index page 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 setpagetype addproducts recommended page type index code example index page example // index page example window\ monetateq = window\ monetateq || \[]; window\ monetateq push(\[ "setpagetype", "index" ]); window\ monetateq push(\[ "addproducts", \[{ "productid" "pidstring1", "sku" "optionalskustring1" }, { "productid" "pidstring2", "sku" "optionalskustring2" }, { "productid" "pidstring3", "sku" "optionalskustring3" }, { "productid" "pidstring4", "sku" "optionalskustring4" }, { "productid" "pidstring5", "sku" "optionalskustring5" } ] window\ monetateq push(\[ "trackdata" ]); search page 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 setpagetype addproducts recommended page type search code example search page example // search page example window\ monetateq = window\ monetateq || \[]; window\ monetateq push(\[ "setpagetype", "search" ]); window\ monetateq push(\[ "addproducts", \[ { "productid" "pidstring1", "sku" "optionalskustring1" }, { "productid" "pidstring2", "sku" "optionalskustring2" }, { "productid" "pidstring3", "sku" "optionalskustring3" }, { "productid" "pidstring4", "sku" "optionalskustring4" }, { "productid" "pidstring5", "sku" "optionalskustring5" }] ]) window\ monetateq push(\[ "trackdata" ]); product detail page 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 setpagetype addproductdetails recommended page type product code example product detail page example // product page example window\ monetateq = window\ monetateq || \[]; window\ monetateq push(\[ "setpagetype", "product" ]); window\ monetateq push(\[ "addproductdetails", \[{ productid "pidstring", sku "optionalskustring" }] ]); window\ monetateq push(\[ "trackdata" ]); cart page 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 setpagetype addcartrows recommended page type cart code example cart page example // cart page example window\ monetateq = window\ monetateq || \[]; window\ monetateq push(\[ "setpagetype", "cart" ]); window\ monetateq push(\[ "addcartrows", \[{ "productid" "a123", "sku" "c678", "quantity" "1", "unitprice" "99 99", "currency" "usd" }, { "productid" "b345", "sku" "d987", "quantity" "3", "unitprice" "29 99", "currency" "usd" }] ]); window\ monetateq push(\[ "trackdata" ]); checkout page the checkout page shows registered users a summary of their order details method calls setpagetype recommended page type checkout checkout page example // checkout page example window\ monetateq = window\ monetateq || \[]; window\ monetateq push(\[ "setpagetype", "checkout" ]); window\ monetateq push(\[ "trackdata" ]); purchase confirmation page the purchase confirmation page loads after a customer has completed a transaction method calls setpagetype addpurchaserows recommended page type purchase code example purchase page example // purchase page example window\ monetateq = window\ monetateq || \[]; window\ monetateq push(\[ "setpagetype", "purchase" ]); "window\ monetateq push(\[ "addpurchaserows", \[{ "purchaseid" "73893797", "productid" "a123", "sku" "c678", "quantity" "1", "unitprice" "99 99", "currency" "eur" }, { "purchaseid" "73893797", "productid" "b345", "sku" "d987", "quantity" "3", "unitprice" "29 99", "currency" "eur" }] ]); window\ monetateq push(\[ "trackdata" ]);