Documentation
Feedback
Guides
VTEX IO Apps

VTEX IO Apps
UseInsider Documentation
Community extension
Version: 1.0.120
Latest version: 1.0.120

The specified version of the app (1.x.0) does not exist. This page is about the latest stable version, which is 1.0.120.

UseInsider integrate vtex stores with Insider plataform.

App Implementation

Instalation

Install the app with the following command: vtex install codeby.userinsider@1.x

Admin Configuration

Open the app settings on your admin and fill the form with Partner ID and Partner Name. You can find yours at the Use Insider Main page.

Advanced Settings

In the advanced settings section, you can set the minicart custom pixel event id. This is used to open the Minicart on Insider AddToCart function. To find what you need to set, check the prop "customPixelEventId" on the "minicart.v2" block of your theme and set the same value.

app settings panel path link: https://{AccountName}.myvtex.com/admin/apps/codeby.useinsider@{AppVersion}/setup/

Checkout Page Configuration

Add the following snippet on the file checkout6-custom.js and replace "YOUR-PARTNER-ID" and "YOUR-PARTNER-NAME” with your UseInsider "partnerId" and "partnerName":


_22
(function (window) {
_22
const partnerId = 'YOUR-PARTNER-ID'
_22
const partnerName = 'YOUR-PARTNER-NAME'
_22
_22
const domainName = window.location.origin
_22
const insiderUrl =
_22
domainName +
_22
'/insider/checkout-script?partnerId=' +
_22
partnerId +
_22
'&partnerName=' +
_22
partnerName
_22
_22
const xmlHttp = new XMLHttpRequest()
_22
xmlHttp.open('GET', insiderUrl, false)
_22
xmlHttp.send(null)
_22
_22
const importScript = document.createElement('script')
_22
importScript.type = 'text/javascript'
_22
importScript.id = 'insider-checkout'
_22
importScript.text = xmlHttp.responseText
_22
document.head.appendChild(importScript)
_22
})(window)

If your theme is not using the checkout-ui-custom application, add the snippet right in the checkout6-custom.js file located in the checkout configuration interface in the admin

file path link:

https:///{AccountName}.myvtex.com/admin/portal/#/sites/default/code/files/checkout6-custom.js

Data information that the app gets and sends

the application collects data from the user and the current navigation page and sends it in json format called insider_object, see examples of the structure and data collected by insider_object in different pages:

Home Page


_22
{
_22
"page": {
_22
"type": "Home"
_22
},
_22
"user": {
_22
"uuid": "201d5ca5-d7ad-4de9-96a4-67e08355c415",
_22
"gender": null,
_22
"birthday": null,
_22
"name": "matheus",
_22
"surname": "cabe",
_22
"username": "matheus",
_22
"email": "[matheus.pessoa@keyrus.com.br](mailto:matheus.pessoa@keyrus.com.br)",
_22
"phone_number": null,
_22
"email_optin": false,
_22
"sms_optin": false,
_22
"language": "pt-BR",
_22
"has_transacted": false,
_22
"transaction_count": 0,
_22
"gdpr_optin": true,
_22
"return": true
_22
}
_22
}

Search/Category/Department Pages


_48
{
_48
"page": {
_48
"type": "Category"
_48
},
_48
"listing": {
_48
"items": [
_48
{
_48
"id": "20",
_48
"name": "Acer Aspire 5 Slim Laptop - Windows 10",
_48
"currency": "BRL",
_48
"product_image_url": "[https://codeby.vtexassets.com/arquivos/ids/160993/acer-aspire-5-slim-laptop-a515-43-r19l-silver.jpg?v=1777206750](https://codeby.vtexassets.com/arquivos/ids/160993/acer-aspire-5-slim-laptop-a515-43-r19l-silver.jpg?v=1777206750)",
_48
"url": "[https://cabeinsider--codeby.myvtex.com/acer-aspire-5-slim-laptop-a515-43-r19l-silver/p](https://cabeinsider--codeby.myvtex.com/acer-aspire-5-slim-laptop-a515-43-r19l-silver/p)",
_48
"taxonomy": ["Computer & Software"],
_48
"unit_price": 3000,
_48
"unit_sale_price": 339.15,
_48
"stock": 10000
_48
},
_48
{
_48
"id": "18",
_48
"name": "Acer Aspire TC-885-UA92 Desktop - Windows 10",
_48
"currency": "BRL",
_48
"product_image_url": "[https://codeby.vtexassets.com/arquivos/ids/160992/acer-aspire-atc-885-ua92-desktop.jpg?v=1774652597](https://codeby.vtexassets.com/arquivos/ids/160992/acer-aspire-atc-885-ua92-desktop.jpg?v=1774652597)",
_48
"url": "[https://cabeinsider--codeby.myvtex.com/acer-aspire-atc-885-ua92-desktop/p](https://cabeinsider--codeby.myvtex.com/acer-aspire-atc-885-ua92-desktop/p)",
_48
"taxonomy": ["Computer & Software"],
_48
"unit_price": 3000,
_48
"unit_sale_price": 1287,
_48
"stock": 10000
_48
}
_48
]
_48
},
_48
"user": {
_48
"uuid": "201d5ca5-d7ad-4de9-96a4-67e08355c415",
_48
"gender": null,
_48
"birthday": null,
_48
"name": "matheus",
_48
"surname": "cabe",
_48
"username": "matheus",
_48
"email": "[matheus.pessoa@keyrus.com.br](mailto:matheus.pessoa@keyrus.com.br)",
_48
"phone_number": null,
_48
"email_optin": false,
_48
"sms_optin": false,
_48
"language": "pt-BR",
_48
"has_transacted": false,
_48
"transaction_count": 0,
_48
"gdpr_optin": true,
_48
"return": true
_48
}
_48
}

Product Page


_38
{
_38
"product": {
_38
"id": "32",
_38
"groupcode": "20",
_38
"name": "Acer Aspire 5 Slim Laptop - Windows 10",
_38
"url": "[https://cabeinsider--codeby.myvtex.com/acer-aspire-5-slim-laptop-a515-43-r19l-silver/p?skuId=32](https://cabeinsider--codeby.myvtex.com/acer-aspire-5-slim-laptop-a515-43-r19l-silver/p?skuId=32)",
_38
"product_image_url": "[https://codeby.vtexassets.com/arquivos/ids/160993/acer-aspire-5-slim-laptop-a515-43-r19l-silver.jpg?v=637580597517300000](https://codeby.vtexassets.com/arquivos/ids/160993/acer-aspire-5-slim-laptop-a515-43-r19l-silver.jpg?v=637580597517300000)",
_38
"taxonomy": ["Computer & Software"],
_38
"unit_price": 3000,
_38
"unit_sale_price": 339.15,
_38
"stock": 1000000,
_38
"currency": "BRL",
_38
"custom": {
_38
"brand": "Brand",
_38
"brandId": 9280,
_38
"productReference": "880019",
_38
"linkText": "acer-aspire-5-slim-laptop-a515-43-r19l-silver",
_38
"categoryId": "9286",
_38
"taxonomy": ["Computer & Software"],
_38
"unit_price": 3000,
_38
"unit_sale_price": 339.15
_38
}
_38
},
_38
"page": {
_38
"type": "Product"
_38
},
_38
"user": {
_38
"uuid": "201d5ca5-d7ad-4de9-96a4-67e08355c415",
_38
"birthday": null,
_38
"email_optin": false,
_38
"sms_optin": false,
_38
"has_transacted": false,
_38
"transaction_count": 0,
_38
"gdpr_optin": true,
_38
"return": true,
_38
"language": "pt-BR"
_38
}
_38
}

Cart Page


_54
{
_54
"basket": {
_54
"line_items": [
_54
{
_54
"product": {
_54
"id": "32",
_54
"name": "Acer Aspire 5 Slim Laptop - Windows 10",
_54
"taxonomy": ["Computer & Software"],
_54
"unit_price": 339.15,
_54
"unit_sale_price": 339.15,
_54
"currency": "BRL",
_54
"url": "[https://cabeinsider--codeby.myvtex.com/acer-aspire-5-slim-laptop-a515-43-r19l-silver/p](https://cabeinsider--codeby.myvtex.com/acer-aspire-5-slim-laptop-a515-43-r19l-silver/p)",
_54
"product_image_url": "[https://codeby.vteximg.com.br/arquivos/ids/160993/acer-aspire-5-slim-laptop-a515-43-r19l-silver.jpg?v=637580597517300000](https://codeby.vteximg.com.br/arquivos/ids/160993/acer-aspire-5-slim-laptop-a515-43-r19l-silver.jpg?v=637580597517300000)",
_54
"stock": 1000000,
_54
"groupcode": "20",
_54
"custom": {
_54
"brand": "Brand",
_54
"brandId": 9280,
_54
"categoryId": "9286",
_54
"linkText": "acer-aspire-5-slim-laptop-a515-43-r19l-silver",
_54
"productReference": "880019",
_54
"taxonomy": ["Computer & Software"],
_54
"unit_price": 339.15,
_54
"unit_sale_price": 339.15
_54
}
_54
},
_54
"quantity": 1,
_54
"subtotal": 339.15
_54
}
_54
],
_54
"currency": "BRL",
_54
"total": 339.15
_54
},
_54
"page": {
_54
"type": "Basket"
_54
},
_54
"user": {
_54
"uuid": "201d5ca5-d7ad-4de9-96a4-67e08355c415",
_54
"gender": null,
_54
"birthday": null,
_54
"name": null,
_54
"surname": null,
_54
"username": "matheus",
_54
"email": "[matheus.pessoa@keyrus.com.br](mailto:matheus.pessoa@keyrus.com.br)",
_54
"phone_number": null,
_54
"email_optin": null,
_54
"sms_optin": false,
_54
"language": "pt-BR",
_54
"has_transacted": false,
_54
"transaction_count": 0,
_54
"gdpr_optin": true,
_54
"return": true
_54
}
_54
}

OrderPlaced Page


_62
{
_62
"user": {
_62
"uuid": "201d5ca5-d7ad-4de9-96a4-67e08355c415",
_62
"gender": null,
_62
"birthday": null,
_62
"name": "matheus",
_62
"surname": "cabe",
_62
"username": "matheus",
_62
"email": "matheus.pessoa@keyrus.com.br",
_62
"phone_number": null,
_62
"email_optin": false,
_62
"sms_optin": false,
_62
"language": "pt-BR",
_62
"has_transacted": false,
_62
"transaction_count": 0,
_62
"gdpr_optin": true,
_62
"return": true
_62
},
_62
"transaction": {
_62
"order_id": "1351550508867",
_62
"currency": "BRL",
_62
"total": 374.24,
_62
"payment_type": "bankInvoice",
_62
"shipping_cost": 35.09,
_62
"delivery": {
_62
"country": "BRA",
_62
"city": "São Paulo",
_62
"district": "SP"
_62
},
_62
"line_items": [
_62
{
_62
"product": {
_62
"id": "32",
_62
"name": "Acer Aspire 5 Slim Laptop - Windows 10",
_62
"taxonomy": ["Computer & Software"],
_62
"unit_price": 339.15,
_62
"unit_sale_price": 339.15,
_62
"currency": "BRL",
_62
"url": "https://cabeinsider--codeby.myvtex.com/acer-aspire-5-slim-laptop-a515-43-r19l-silver/p",
_62
"product_image_url": "https://codeby.vteximg.com.br/arquivos/ids/160993/acer-aspire-5-slim-laptop-a515-43-r19l-silver.jpg?v=637580597517300000",
_62
"stock": 1000000,
_62
"groupcode": "20",
_62
"custom": {
_62
"brand": "Brand",
_62
"brandId": 9280,
_62
"categoryId": "9286",
_62
"linkText": "acer-aspire-5-slim-laptop-a515-43-r19l-silver",
_62
"productReference": "880019",
_62
"taxonomy": ["Computer & Software"],
_62
"unit_price": 339.15,
_62
"unit_sale_price": 339.15
_62
}
_62
},
_62
"quantity": 1,
_62
"subtotal": 339.15
_62
}
_62
]
_62
},
_62
"page": {
_62
"type": "Confirmation"
_62
}
_62
}

How it works in technical terms at VTEX

The app works based on VTEX Pixel events. These events are mapped in the “/react/index.ts” file, inside the “handleMessages” function, where whenever one of the events is triggered, the function will properly deal with the received data, setting up the insider_object according to the model of each page, so that the Insider script collects the data correctly.

For more detailed information, access this VTEX documentation: https://developers.vtex.com/docs/guides/vtex-io-documentation-6-listeningtostoreevents

Pixel Events Used

vtex:pageInfo

Fired whenever the page is loaded. When the user is on the home page, responsible for adding the insider_object attribute:


_10
{
_10
page: {
_10
type: 'Home'
_10
}
_10
}

vtex:departmentView, vtex:categoryView E vtex:internalSiteSearchView

Triggered whenever the department, category, or search page is loaded. Responsible for adding the attributes to the insider_object:


_10
{
_10
page: { type: 'Category' | 'Search' },
_10
listing: { items: 'PRODUCTS LIST' }
_10
}

vtex:pageView

Fired whenever the any page is loaded. Responsible for adding the insider_object attribute:


_10
{
_10
page: {
_10
type: 'CURRENT PAGE TYPE'
_10
}
_10
}

In addition, it also triggers the event to reinitialize the “Insider” (init-manager:re-initialize)

vtex:userData

Fired after page load. Responsible for fetching authenticated user information via API and adding the attribute to the insider_object:


_10
{ user: {{USER DATA}} }

If the user is not authenticated, the data added will be from a template.

vtex:addToCart

Fired whenever a product is added to the cart. Responsible for adding the insider_object attribute:


_10
{
_10
basket: {
_10
currency: currency,
_10
total: items.length,
_10
line_items: parseItems(items, currency)
_10
}
_10
}

this attribute contains information about the added product.

vtex:productView

Fired whenever the product page is loaded. Responsible for adding the product and page information to the insider_object with the attributes:


_10
{
_10
page: { type: 'Product' },
_10
product: {{PRODUCT DATA}}
_10
}

vtex:orderPlaced

Fired whenever the order placed page is executed. Responsible for adding the attributes to the insider_object:


_10
{
_10
page: { type: 'Confirmation' },
_10
transaction: {{DADOS DA TRANSAÇÃO}}
_10
}

Custom Pixel Events for VTEX

In some cases of stores with the Insider app installed, it is necessary to customize certain specific components. If this is indeed required, you will also need to add custom events for VTEX to understand the data you are handling.

Add dependency on your manifest.json, like this:


_10
{
_10
"dependencies": {
_10
"vtex.pixel-manager": "1.x"
_10
}
_10
}

How to import the VTEX hook:


_10
import { usePixel } from 'vtex.pixel-manager'

Which function to use to send the event:


_10
const { push } = usePixel()

How to send the event and what information needs to be sent for each event:

vtex:addToCart

If you need to create a custom add-to-cart button, you will need to add the following event:


_26
push({
_26
id: 'add-to-cart-button',
_26
event: 'addToCart',
_26
items: [
_26
{
_26
brand: 'brand',
_26
category: 'category-1/category-2/category-3',
_26
detailUrl: '/acer-aspire-5-slim-laptop-a515-43-r19l-silver/p',
_26
ean: '4909603621958',
_26
imageUrl:
_26
'https://codeby.vtexassets.com/arquivos/ids/160992/acer-aspire-atc-885-ua92-desktop.jpg',
_26
name: 'Acer Aspire 5 Slim Laptop - Windows 10',
_26
price: 3000,
_26
priceIsInt: true,
_26
productId: '20',
_26
productRefId: 'MP2018.130',
_26
quantity: 1,
_26
referenceId: 'MP2018.130',
_26
seller: '1',
_26
sellerName: 'sellerName',
_26
sellingPrice: 2500,
_26
skuId: '1367',
_26
variant: 'Acer Aspire 5 Slim Laptop - Windows 11',
_26
},
_26
],
_26
})

vtex:productView

We have two cases where it is necessary to call the 'productView' event on the product page, upon page load and when changing the product SKU. In both cases, it is necessary to send the event to VTEX.

  • Page Load: If for any reason we have a completely customized page that would simulate a product page, add the event upon page load.

  • Product SKU Change: If for any reason we have the 'sku-selector' block customized, add the event every time the page's SKU changes.

Event to add on VTEX pixel:


_89
push({
_89
currency: 'BRL',
_89
event: 'productView',
_89
product: {
_89
detailUrl: '/acer-aspire-5-slim-laptop-a515-43-r19l-silver/p',
_89
brand: 'brand',
_89
brandId: 9280,
_89
productReference: '880019',
_89
linkText: 'acer-aspire-5-slim-laptop-a515-43-r19l-silver',
_89
categoryId: '9286',
_89
categories: ['/notebooks/acer/silver/', '/notebooks/acer/', '/notebooks/'],
_89
categoryTree: [
_89
{
_89
id: 1,
_89
name: 'notebooks',
_89
href: '/notebooks',
_89
__typename: 'Category',
_89
},
_89
{
_89
id: 10,
_89
name: 'acer',
_89
href: '/notebooks/acer',
_89
__typename: 'Category',
_89
},
_89
{
_89
id: 13,
_89
name: 'silver',
_89
href: '/notebooks/acer/silver',
_89
__typename: 'Category',
_89
},
_89
],
_89
productId: '20',
_89
productName: 'Acer Aspire 5 Slim Laptop - Windows 10',
_89
items: [
_89
{
_89
itemId: '1351',
_89
name: 'Acer Aspire 5 Slim Laptop - Windows 10',
_89
ean: '4909603621958',
_89
referenceId: [
_89
{
_89
Key: 'RefId',
_89
Value: 'MP2018.130',
_89
__typename: 'Reference',
_89
},
_89
],
_89
imageUrl:
_89
'https://codeby.vtexassets.com/arquivos/ids/160992/acer-aspire-atc-885-ua92-desktop.jpg',
_89
sellers: [
_89
{
_89
sellerId: '1',
_89
sellerName: 'sellerName',
_89
sellerDefault: true,
_89
commertialOffer: {
_89
Price: 3000,
_89
ListPrice: 2500,
_89
AvailableQuantity: 4392,
_89
},
_89
},
_89
],
_89
},
_89
],
_89
selectedSku: {
_89
itemId: '1351',
_89
name: 'Acer Aspire 5 Slim Laptop - Windows 10',
_89
ean: '4909603621958',
_89
referenceId: [
_89
{
_89
Key: 'RefId',
_89
Value: 'MP2018.130',
_89
__typename: 'Reference',
_89
},
_89
],
_89
imageUrl:
_89
'https://codeby.vtexassets.com/arquivos/ids/160992/acer-aspire-atc-885-ua92-desktop.jpg',
_89
sellers: [
_89
{
_89
sellerId: '1',
_89
sellerName: 'sellerName',
_89
sellerDefault: true,
_89
commertialOffer: {
_89
Price: 3000,
_89
ListPrice: 2500,
_89
AvailableQuantity: 4392,
_89
},
_89
},
_89
],
_89
},
_89
},
_89
})

Advanced Options

The data mentioned above that the app collects is the default data. However, now you have the ability to insert custom attributes into the insider_object.

The app exports the following JavaScript function into the window object:


_10
window.insertCustomAttrInsider('subObject', 'customObject')

The first argument is the subObject. The subObject supported is the same as as what Insider supports, as mentioned in the Insider documentation

Supported subObject are:


_10
1. page
_10
2. user
_10
3. listing
_10
4. product
_10
5. basket
_10
6. transaction

The second argument is the object of your custom properties. You can insert any object with any property and values here

So, if you want to add a custom attribute like whatsapp_optin to the user subObject and a custom attribute, you can do the following:


_10
const customFields = {
_10
whatsapp_option: true,
_10
custom: {
_10
some_property: 'value',
_10
},
_10
}
_10
window.insertCustomAttrInsider('user', customFields)

After doing that, your insider_object will look like this:


_26
{
_26
"page": {
_26
"type": "Home"
_26
},
_26
"user": {
_26
"uuid": "fh23fe1d-f01e-4cee-85f0-c4dc25c09e57",
_26
"gender": null,
_26
"birthday": null,
_26
"name": null,
_26
"surname": null,
_26
"username": null,
_26
"email": "user.email@codeby.com.br",
_26
"phone_number": null,
_26
"email_optin": false,
_26
"sms_optin": false,
_26
"language": "pt-BR",
_26
"has_transacted": false,
_26
"transaction_count": 0,
_26
"gdpr_optin": true,
_26
"return": true,
_26
"custom": {
_26
"some_property": "value"
_26
},
_26
"whatsapp_optin": true
_26
}
_26
}

New Function: AddToCart

A new function has been added to the app and is available on the global window object as AddToCart. This function enables you to add a product directly to the cart programmatically.


_10
window.AddToCart(SKU, Quantity, Seller)

Parameters SKU (string): The Stock Keeping Unit of the product. The SKU represents the physical unit and product variation, containing the unique characteristics that define the specific type of product.

Quantity (integer): The number of units of the product to be added to the cart.

Seller (string): The seller. In VTEX, products can be supplied by multiple sellers, making it important to specify the seller from which the product is sourced.


_10
// Example: Add 2 units of the product with SKU '123' from seller '1'
_10
window.AddToCart('123', 2, '1')

Note: This function is available only within the VTEX IO environment. For example, checkout pages are not built on VTEX IO, so the AddToCart function is not available there.

See also
VTEX App Store
VTEX IO Apps
UseInsider_Documentation
VTEX IO Apps