Create a new action for an order page. This should only be used on order
confirmation / thank you pages.
You do not need to specify the page-type explicitly as it is inferred
from the action.
You must invoke [the load method]Action#load on the resultant
action in order for the request to be made.
the information about the order that was placed
the action instance to load content or track events.
nostojs(api => {
api.defaultSession()
.addOrder({
external_order_ref: "145000006",
info: {
order_number: "195",
email: "mridang@nosto.com",
first_name: "Mridang",
last_name: "Agarwalla",
type: "order",
newsletter: true
},
items: [{
product_id: "406",
sku_id: "243",
name: "Linen Blazer (White, S)",
quantity: 1,
unit_price: 455,
price_currency_code: "EUR"
}]
})
.setPlacements(["order-related"])
.load()
.then(data => {
console.log(data.recommendations);
})
})
Creates an action to report that product was added to the shopping cart, e.g. from the recommendation slot with "Add to cart" button.
You must invoke [the load method]Action#load on the resultant action in order for the request to be made.
the action instance to load content or track events.
Sets the information about the user's current shopping cart. It the user does not have any items in his shopping cart, you can pass null. Passing null will nullify the user's shopping cart on Nosto's end. You must also pass in the shopping cart content in it's entirety as partial content are not supported.
the details of the user's shopping cart contents
the current session
Sets the information about the currently logged in customer. If the current customer is not provided, you will not be able to leverage features such as triggered emails. While it is recommended to always provide the details of the currently logged in customer, it may be omitted if there are concerns about privacy or compliance.
the details of the currently logged in customer
the current session
nostojs(api => api
.defaultSession()
.setCustomer({
first_name: "Mridang",
last_name: "Agarwalla",
email: "mridang@nosto.com",
newsletter: false,
customer_reference: "5e3d4a9c-cf58-11ea-87d0-0242ac130003"
})
.viewCart()
.setPlacements(["free-shipper"])
.load()
.then(data => console.log(data)))
Sets the response type to HTML or JSON_ORIGINAL. This denotes the preferred response type of the recommendation result. If you would like to access the raw recommendation data in JSON form, specify JSON. When you specify JSON, you will need to template the result yourself. If you require a more simplified approach, specify HTML. When you specify HTML, you get back HTML blobs, that you may simply inject into you placements.
the response mode for the recommendation data
the current session
Sets the restore link for the current session. Restore links can be leveraged
in email campaigns. Restore links allow the the user to restore the cart
contents in a single click.
Read more about
to leverage the restore cart link
the secure URL to restore the user's current session
the current session
Sets the current variation identifier for the session. A variation identifier identifies the current currency (or the current customer group). If your site uses multi-currency, you must provide the ISO code current currency being viewed.
the case-sensitive identifier of the current variation
the current session
Create a new action for a cart page. This should be used on all cart and
checkout pages. If your site has a multi-step checkout, it is recommended
that you send this event on each checkout page.
You must invoke [the load method]Action#load on the resultant
action in order for the request to be made.
You do not need to specify the page-type explicitly as it is inferred
from the action.
the action instance to load content or track events.
Create a new action for a category page. This should be used on all
category, collection of brand pages.
You must invoke [the load method]Action#load on the resultant
action in order for the request to be made.
You do not need to specify the page-type explicitly as it is inferred
from the action.
the action instance to load content or track events.
Create a new action with custom fields.
You must invoke [the load method]Action#load on the resultant
action in order for the request to be made.
You do not need to specify the page-type explicitly as it is inferred
from the action.
Note: tags are not case-sensitive.
custom fields being viewed.
the action instance to load content or track events.
Create a new action for a front page. This should be used when the user
visits the home page.
You must invoke [the load method]Action#load on the resultant
action in order for the request to be made.
You do not need to specify the page-type explicitly as it is inferred
from the action.
the action instance to load content or track events.
Create a new action for a not found page. This should be used only on 404
pages.
You must invoke [the load method]Action#load on the resultant
action in order for the request to be made.
You do not need to specify the page-type explicitly as it is inferred
from the action.
the action instance to load content or track events.
Create a new action for a general page. This should be used only on
pages that don't have a corresponding action. For example, if the user
is viewing a page such as a "Contact Us" page, you should use the viewOther
action.
You must invoke [the load method]Action#load on the resultant
action in order for the request to be made.
You do not need to specify the page-type explicitly as it is inferred
from the action.
the action instance to load content or track events.
Create a new action for a product page. This must be used only when a
product is being viewed. In case a specific SKU of the product is being viewed, use viewProductSku instead.
You must invoke [the load method]Action#load on the resultant
action in order for the request to be made.
You do not need to specify the page-type explicitly as it is inferred
from the action.
the action instance to load content or track events.
Create a new action for a product page when a specific SKU has been chosen. This must be used only when a
product and specific SKU is being viewed.
You must invoke [the load method]Action#load on the resultant
action in order for the request to be made.
You do not need to specify the page-type explicitly as it is inferred
from the action.
the action instance to load content or track events.
Create a new action for a search page. This should be used only
on search pages. A search page action requires you to pass the search
term. For example, if the user search for "black shoes", you must pass
in "black shoes" and not an encoded version such as "black+shoes".
You must invoke [the load method]Action#load on the resultant
action in order for the request to be made.
You do not need to specify the page-type explicitly as it is inferred
from the action.
Search terms are not case-sensitive.
the non-encoded search terms
the action instance to load content or track events.
Create a new action for a tag page. This should be used only on tag pages.
You must invoke [the load method]Action#load on the resultant
action in order for the request to be made.
You do not need to specify the page-type explicitly as it is inferred
from the action.
Note: tags are not case-sensitive.
the set of the tags being viewed.
the action instance to load content or track events.
The Session API provides a programmatic way to interact with the Nosto API that is optimized for usage in SPA style web applications. The Session object maintains the session level data such as the user's shopping cart, the currently logged in customer, the current variation and provides function to execute actions such as viewing a product, category, cart, order etc.