Find the JavaScript and HTML code required to render Einstein Recommendations on your page. Copy the code and embed it in your page source for each piece of code.
Customize the provided basic recommendation calls to match your site. The description key in each box shows additional information that you can pass in the JavaScript source URL.
These client parameters aren’t run-time variables. The variables after “?” are supplied in the call at run time.
There are required fields for some pages.
| Page | Required Field |
|---|---|
| Product Detail | ProductCode |
| Category | CategoryName |
| Cart | List of cart ProductCodes |
| Search | Search Term |
Place the div where it’s displayed in the recommendation. Place this value exactly where it appears on the page.
<div id="igdrec_1"></div>.
Next, place a script tag with this code.
<script
src="http://{client_name}.recs.igodigital.com/a/v2/{client}/home/recommend.js"></script>
Place the div where it’s displayed in the recommendation. Place this value exactly where it appears on the page.
<div id="igdrec_1"></div>.
Next, place a script tag with this code.
<script src="http://{client_name}.recs.igodigital.com/a/v2/{client}/product/recommend.js?item=ProductCode"></script>..
ProductCode is the item viewed and must match the same value passed in the Collect
Tracking Code item variable.
Place the div where the recommendation displays. Place this value exactly where it appears on the page.
<div id="igdrec_1"></div>.
Next, place a script tag with this code.
<script
src="http://{client_name}.recs.igodigital.com/a/v2/{client}/category/recommend.js?
category=Category_name"></script>.
Replace Category with the actual category page name where the recommendation call is being made. This code must exactly match the categories stored in the product catalog category.
If the category name includes any spaces or special characters, the URL value must be
encoded. For example, if the category is Category & Name, then the URL
parameter is category=Category%20%26%20Name.
Place the div where the recommendation displays. Place this value exactly where it appears on the page.
<div id="igdrec_1"></div>.
Place a script tag with this code after the div.
<script
src="https://{client_name}.recs.igodigital.com/a/{client}/cart/recommend.js?cart=ProductCode".</script>.
Match the value in ProductCode to the value sent in the Collect Tracking Code cart variable as a pipe-delimited list.