Tracking Events
Instead of using HTML tagging or tagging providers, you will implement the same pattern for event tracking on all page types. Nosto needs to know what is happening during a user's session, mainly page views (like PDPs or PLPs), "add to cart" events and conversions.
Regardless if an event was influenced by a Nosto personalization module (product recommendation/bundle or on-site content like a personalized banner) or not, the fundamental call you make is always the same and varies based on the page type. When a shopper visits the homepage, you will call viewFrontPage(), when a search was made for "black shoes" you will call .viewSearch("black shoes") and so on. All page types are listed with examples below.
Upon viewing the homepage
When viewing a homepage, there's no context to be provided, so invoking the viewFrontPage will suffice.
nostojs(api => {
api.defaultSession()
.viewFrontPage()
.setPlacements(['homepage-nosto-1', 'bestseller-recs'])
.load()
.then(data => {
console.log(data.recommendations);
})
});Upon viewing a product
When viewing a product, you should send the product-id of the current product being viewed. Unlike the regular implementation, you do not need to pass the entirety of the product metadata.
nostojs(api => {
api.defaultSession()
.viewProduct('product-id')
.setPlacements(['product-crosssells'])
.load()
.then(data => {
console.log(data.recommendations);
})
});Upon viewing a product variant
Optional event that can be sent to signal that a specific product variant (SKU in Nosto terms) is being viewed. Typical use case for sending this event would be from product detail page when the user selects a product variant, such as some specific color and/or size. The recommendations can then be configured to update and give preference for products that have similar variants available. For example "Other products also available in the same size". Product variant views are added with the function viewProductSku:
Upon viewing a category
When viewing a category, you should send the fully qualified name of the current category. This is not necessarily the same as the handle of the category used in the address of the category page.
When the category or collection id is available it can be provided via
It is needed for accurate attribution in certain Nosto products such as Category Merchandising.
Tagging the categories
Nested categories must always be delimited by a slash. For example, /Home/Accessories is a valid category while Home > Accessories is not.
Upon doing a search
When viewing the results of a search, you must send the exact search-term as queried for.
Note: You don’t need to normalize or encode the search query in any way.
Upon starting a checkout
When viewing a checkout page, there's no context to be provided, so invoking the viewCart will suffice.
Upon placing an order
On all thank-you and order-confirmation views, the order confirmation metadata must be passed.
The order confirmation metadata is used for sending personalized order-followup emails, personalize the recommendations e.g. order-related, for segmentation insights and conversion statistics.
Important Even if you would not display any recommendations in your order-confirmation view you must still set placements (.setPlacements(...)) and load (.load()) the results. Setting the order works in a similar manner than cart and customer and an action must be performed for the data to be sent to Nosto.
Upon viewing a page that was not found (404)
When viewing a page / view that was not found, there's no context to be provided, so invoking the viewNotFound will suffice.
Upon viewing a general page
When a page with a type - other than the ones listed here - is viewed, there's no context to be provided, so invoking the viewOther will suffice.
See also
To learn more about the api.defaultSession usage, please refer to the official API documentation.
Last updated
Was this helpful?