Product object is required for revenue tracking, recommendation engine, and campaigns such as cart reminder. This guide explains how you can set the product object and product attributes.
Set product object
Once you create a product object, you can set its attributes. You can set predefined (e.g., color, size, voucher name, sub-category, etc.) and custom attributes.
The following parameters are required for the product object:
| Parameter | Data Type |
|---|---|
| productID | String |
| name | String |
| taxonomy | Array (of string) |
| imageURL | String |
| price | Number |
| currency | String |
Method Signature
createNewProduct(productId: string, name: string, taxonomy: object, imageURL: string, price: number, currency: string): ProductMethod Example
const taxonomy = ['taxonomy1', 'taxonomy2', 'taxonomy3'];
var product = window.Insider.createNewProduct('product_id',
'Apple',
taxonomy,
'imageURL',
1000.5,
'currency');Set color attribute
This method allows you to set the color attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| color | String |
Method Signature
setColor(color: string):Product;Method Example
var product = window.Insider.createNewProduct('product_id',
'Apple',
taxonomy,
'imageURL',
1000.5,
'currency');
product.setColor("red");Set voucher name attribute
This method allows you to set the voucher name attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| voucherName | String |
Method Signature
(voucherName: string):Product;Method Example
var product = window.Insider.createNewProduct('product_id',
'Apple',
taxonomy,
'imageURL',
1000.5,
'currency');
product.voucherName("voucherName");Set voucher discount attribute
This method allows you to set the voucher discount attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| voucherDiscount | Number |
Method Signature
setVoucherDiscount(voucherDiscount: number):Product;Method Example
var product = window.Insider.createNewProduct('product_id',
'Apple',
taxonomy,
'imageURL',
1000.5,
'currency');
product.setVoucherDiscount(10.5);Set promotion name attribute
This method allows you to set the promotion name attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| promotionName | String |
Method Signature
setPromotionName(promotionName: string):Product;Method Example
var product = window.Insider.createNewProduct('product_id',
'Apple',
taxonomy,
'imageURL',
1000.5,
'currency');
product.setPromotionName("promotionName");Set promotion discount attribute
This method allows you to set the promotion discount attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| promotionDiscount | Number |
Method Signature
setPromotionDiscount(promotionDiscount: number):Product;Method Example
var product = window.Insider.createNewProduct('product_id',
'Apple',
taxonomy,
'imageURL',
1000.5,
'currency');
product.setPromotionDiscount(10.5);Set GroupCode attribute
This method allows you to set the groupcode of your Insider product object.
| Parameter | Data Type |
|---|---|
| groupcode | String |
Method Signature
setGroupCode(groupcode: string):Product;Method Example
insiderExampleProduct.setGroupCode("XXXX")Set size attribute
This method allows you to set the size attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| size | String |
Method Signature
setSize(size: string):Product;Method Example
var product = window.Insider.createNewProduct('product_id',
'Apple',
taxonomy,
'imageURL',
1000.5,
'currency');
product.setSize("size");Set sale price attribute
This method allows you to set the sale price attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| salePrice | Number |
Method Signature
salePrice(salePrice: number):Product;Method Example
var product = window.Insider.createNewProduct('product_id',
'Apple',
taxonomy,
'imageURL',
1000.5,
'currency');
product.salePrice(10.5);Set shipping cost attribute
This method allows you to set the shipping cost attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| shippingCost | Number |
Method Signature
setShippingCost(shippingCost: number):Product;Method Example
var product = window.Insider.createNewProduct('product_id',
'Apple',
taxonomy,
'imageURL',
1000.5,
'currency');
product.setShippingCost(10.5);Set quantity attribute
This method allows you to set the quantity attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| quantity | Number |
Method Signature
setQuantity(quantity: number):Product;Method Example
var product = window.Insider.createNewProduct('product_id',
'Apple',
taxonomy,
'imageURL',
1000.5,
'currency');
product.setQuantity(10);Set stock attribute
This method allows you to set the stock attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| stock | Number |
Method Signature
setStock(stock: number):Product;Method Example
var product = window.Insider.createNewProduct('product_id',
'Apple',
taxonomy,
'imageURL',
1000.5,
'currency');
product.setStock(10);Set brand attribute
This method allows you to set the brand for your Insider product object.
Method Signature
setBrand(brand: string)Method Example
insiderExampleProduct.setBrand('myBrand');Set stock keeping unit attribute
This method allows you to set the stock keeping unit for your Insider product object.
Method Signature
setSku(sku: string)Method Example
insiderExampleProduct.setSku('SKU123456');Set gender attribute
This method allows you to set the gender for your Insider product object.
Method Signature
setGender(gender: Insider.gender)
Method Example
insiderExampleProduct.setGender('male');Set multipack attribute
This method allows you to set the multipack for your Insider product object.
Method Signature
setMultipack(multipack: string)Method Example
insiderExampleProduct.setMultipack('2-pack');Set product type attribute
This method allows you to set the product type for your Insider product object.
Method Signature
setProductType(productType: string)Method Example
insiderExampleProduct.setProductType('Footwear');Set global trade item number attribute
This method allows you to set the global trade item number for your Insider product object.
Method Signature
setGtin(gtin: string)Method Example
insiderExampleProduct.setGtin('1234567890123');Set description attribute
This method allows you to set the description for your Insider product object.
Method Signature
setDescription(description: string)Method Example
insiderExampleProduct.setDescription('Breathable running shoes');Set tags attribute
This method allows you to set the tags for your Insider product object.
Method Signature
setTags(tags: string[])Method Example
var tags = ['running', 'summer', 'discount'];
insiderExampleProduct.setTags(tags);Set custom string attribute
This method allows you to set the custom string attribute for your Insider product object.
| Parameter | Data Type |
|---|---|
| key | String |
| value | String |
Method Signature
setCustomAttributeWithString(key: string,value: number):Product;Method Example
var product = window.Insider.createNewProduct('product_id',
'Apple',
taxonomy,
'imageURL',
1000.5,
'currency');
product.setCustomAttributeWithString('string_parameter', 'This is Insider.')Set custom integer attribute
This method allows you to set the custom integer attribute for your Insider product object.
| Parameter | Data Type |
|---|---|
| key | String |
| value | Number |
Method signature
setCustomAttributeWithInteger(key: string,value: number):Product;Method Example
var product = window.Insider.createNewProduct('product_id',
'Apple',
taxonomy,
'imageURL',
1000.5,
'currency');
product.setCustomAttributeWithInt('key', 10)Set custom boolean attribute
This method allows you to set the custom boolean attribute for your Insider product object.
| Parameter | Data Type |
|---|---|
| key | String |
| value | Boolean |
Method Signature
setCustomAttributeWithBoolean(key: string,value: boolean):Product;Method Example
var product = window.Insider.createNewProduct('product_id',
'Apple',
taxonomy,
'imageURL',
1000.5,
'currency');
product.setCustomAttributeWithBoolean('key', true)Set custom double attribute
This method allows you to set the custom double attribute for your Insider product object.
| Parameter | Data Type |
|---|---|
| key | String |
| value | Number |
Method Signature
setCustomAttributeWithDouble(key: string,value: number):Product;Method Example
var product = window.Insider.createNewProduct('product_id',
'Apple',
taxonomy,
'imageURL',
1000.5,
'currency');
product.setCustomAttributeWithDouble('key', 10.5)Set custom date attribute
This method allows you to set the custom date attribute for your Insider product object.
| Parameter | Data Type |
|---|---|
| key | String |
| value | Date |
Method Signature
setCustomAttributeWithDate(key: string,value: Date):Product;Method Example
var product = window.Insider.createNewProduct('product_id',
'Apple',
taxonomy,
'imageURL',
1000.5,
'currency');
product.setCustomAttributeWithDate('key', new Date())Set custom array of string attribute
This method allows you to set the custom array of string attribute for your Insider product object.
| Parameter | Data Type |
|---|---|
| key | String |
| value | Array (of string) |
Method Signature
setCustomAttributeWithStringArray(key: string, value: Array<string>): ProductMethod Example
const stringArray = ['value1', 'value2', 'value3'];
insiderExampleProduct.setCustomAttributeWithStringArray('key', stringArray);Set custom array of number attribute
This method allows you to set the custom array of number attribute for your Insider product object.
| Parameter | Data Type |
|---|---|
| key | Number |
| value | Array (of number) |
Method Signature
setCustomAttributeWithNumericArray(key: string, value: Array<number>): ProductMethod Example
const numberArray = [5, 3.14, 100];
insiderExampleProduct.setCustomAttributeWithNumericArray('key', numberArray);