Product object

Prev Next

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.

your title goes here
If you pass any nil/null or empty string to this method, it will return an empty and invalid product object. Any product-related operations will ignore an invalid product object.

The following parameters are required for the product object:

ParameterData Type
productIDString
nameString
taxonomyArray (of string)
imageURLString
priceNumber
currencyString

Method Signature

createNewProduct(productId: string, name: string, taxonomy: object, imageURL: string, price: number, currency: string): Product

Method Example

const taxonomy = ['taxonomy1', 'taxonomy2', 'taxonomy3'];
var product = window.Insider.createNewProduct('product_id',
        'Apple',
        taxonomy,
        'imageURL',
        1000.5,
        'currency');
your title goes here
Make sure to set the attributes in the given data types, and set no attribute as nil/null or as an empty string. 

Set color attribute

This method allows you to set the color attribute of your Insider product object. 

ParameterData Type
colorString

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. 

ParameterData Type
voucherNameString

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. 

ParameterData Type
voucherDiscountNumber

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. 

ParameterData Type
promotionNameString

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. 

ParameterData Type
promotionDiscountNumber

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. 

ParameterData Type
groupcodeString

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. 

ParameterData Type
sizeString

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. 

ParameterData Type
salePriceNumber

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. 

ParameterData Type
shippingCostNumber

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. 

ParameterData Type
quantityNumber

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. 

ParameterData Type
stockNumber

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.

your title goes here
Your attribute key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this attribute will be ignored. You can use underscores.
ParameterData Type
keyString
valueString

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.

your title goes here
Your attribute key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this attribute will be ignored. You can use underscores.
ParameterData Type
keyString
valueNumber

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.

your title goes here
Your attribute key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this attribute will be ignored. You can use underscores.
ParameterData Type
keyString
valueBoolean

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.

your title goes here
Your attribute key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this attribute will be ignored. You can use underscores.
ParameterData Type
keyString
valueNumber

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.

your title goes here
Your attribute key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this attribute will be ignored. You can use underscores.
ParameterData Type
keyString
valueDate

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.

your title goes here
Your attribute key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this attribute will be ignored. You can use underscores.
ParameterData Type
keyString
valueArray (of string)

Method Signature

setCustomAttributeWithStringArray(key: string, value: Array<string>): Product

Method 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.

your title goes here
Your attribute key should be only numbers. Otherwise, this attribute will be ignored.
ParameterData Type
keyNumber
valueArray (of number)

Method Signature

setCustomAttributeWithNumericArray(key: string, value: Array<number>): Product

Method Example

const numberArray = [5, 3.14, 100];
insiderExampleProduct.setCustomAttributeWithNumericArray('key', numberArray);