First steps
Events and Behaviour Tracking
User Data
- Email Builder Review
- Designing your email
- Creating a Synchronized Module
- Setting Responsivity
- Building Smart Containers
- Creating a Gmail Promotions Annotation
- Adding a Rollover Effect
- Adding a Background to an Email
- Adding Anchor Links
- Adding a Video to an Email
- Adding a Table to an Email
- Adding a Custom Font
- Adding Social Media Buttons
- Editing HTML and CSS
- Working with “Images” block
Omnichannel
Automation
Personalization
Analytics
Multilanguage Campaigns
Recommendations
API
Security and Compliance
Integration
Setting Up Passing Recommendations Using the JavaScript API
In order to use eSputnik product recommendation algorithms and customize their display on your side (appearance of blocks, display pages, etc.), follow these steps:
- install the script on the site to track the behavior of site visitors;
- upload product data feed to your eSputnik account;
- set up the passing of recommendations from eSputnik to your website.
Settings Description
The JS API function is required to receive recommendations and their further use in product blocks on the site.
Scripts for receiving recommendations
On the home page and 404 page
eS('getRecommendations', {
'variantId': 'r554v778'
}, function(error, products) {
if (error) {
console.error(error);
return ;
}
});
On the product page
eS('getRecommendations', {
'variantId': 'r554v778',
'productId': 'MX-1512\42'
}, function(error, products) {
if (error) {
console.error(error);
return ;
}
});
On the cart page
eS('getRecommendations', {
'variantId': 'r554v778',
'productIds': ['123', '543534']
}, function(error, products) {
if (error) {
console.error(error);
return ;
}
});
Use the StatusCartPage event to determine the page type and display recommendations on the cart pop-up. Example:
eS('sendEvent', 'StatusCartPage');
On the categories page
eS('getRecommendations', {
'variantId': 'r554v778',
'categoryKey': 'cK'
}, function(error, products) {
if (error) {
console.error(error);
return ;
}
});
The JS API method is asynchronous, which allows not to wait for the execution of other functions on the site.
Request parameters
Name | Type | Example | Description |
variantId |
Required String |
r262v361 |
The unique ID of the recommendation variation in the eSputnik account. |
productId |
Optional String |
MX-1512\42 |
To pass the product ID from the page the user is on. Required parameter for recommendations using the product algorithm (similar products, products that were bought together with some items); for other types of algorithms, it is not necessary to pass. |
productIds |
Optional List |
['123', '543534']
|
To pass a product ID or an array of cart product IDs. Required parameter for recommendations using the product algorithm (similar products, products that were bought together with some items); for other types of algorithms, it is not necessary to pass. |
categoryKey |
Optional String |
Jackets |
To pass the key of the category the user is in. Required parameter for recommendations using a categorical algorithm (personally for you in this category); for other types of algorithms, it is not necessary to pass. |
allFields | Optional Boolean | true\false |
Parameter for determining which product attributes will be in the recommendation request: All (which are available in the product data feed) or only Required: product_id Default parameter setting = false |
Response example
Upon successful submission of the request, you will receive a response similar to the following:
Response body | Type | Description |
|
List<object> | ● product_id - recommended product ID ● container_type must be used when passing the event ProductImpression ● URL contains a link to the product, with an additional parameter for proper web tracking |
Important!
Don’t edit the return value in the URL field for web tracking to work correctly.
Error example
Example | Type | Description |
variantId r262v361 was not found in config |
String |
No such recommendation variant identifier was found. |
Important!
Send the ProductImpressions event after calling and displaying the recommendations block for proper tracking.
To set the appearance of recommendation blocks in eSputnik, please read this guide.