Cart information notification

The “Notify cart information” event is used to describe the shopping cart that the contact has at a given moment. To that end, it notifies via JavaScript the products and state of the cart of a contact by using connectif.managed.sendEvents.

  

This article is part of the guide to create a custom integration.
If your integration is via module, this notification will be inserted into your eCommerce automatically.

 

How to use

The notification of cart information uses the entityInfo option of the sendEvents method to enrich the information of the events sent. This notification describes the complete cart; Connectif is responsible for detecting changes and generating the proper events when a product is added or removed from the cart.

  

This JavaScript notification represents an alternative to implementing the “Current Cart State” Tag in the HTML of your shop or website.

Notify the shopping cart

This object represents a complete shopping cart at a given instant. It includes the following properties:

Nombre Obligatoria Tipo Descripción
cartId Yes string Unique identifier of the cart.
totalQuantity Yes number Total number of products in the cart.
CartRecoveryUrl No Cart recovery url URL associated with the cart through which one can access to recover/purchase all related products.
totalPrice Yes number Total price of the cart.
products Yes Product Basket Item Items contained in the cart, along with their quantities and amounts.

Notify products via Product Basket Item

This object represents the products, their quantities, and their total price in a purchase or shopping cart.

It includes all the properties of the Product type object (more info in Notify product visited event), plus the following:

Nombre Obligatoria Tipo Descripción
quantity Yes number Quantity of units of this product.
price Yes number Accumulated price of the products represented by this Product Basket Item. Usually equals quantity * unitPrice.

 

Other considerations

It is very important to set a cart identifier (“cartId”) and also notify Connectif when the cart is emptied, to avoid generating abandoned cart events.

 

Example

The notification will look like this:

const cart = {
    cartId: '123456789',
    totalQuantity: 1,
    totalPrice: 10.2,
    products: [{
        quantity: 1,
        price: 10.2,
        productDetailUrl: 'https://mywebsite.com/myproduct-detail-url',
        productId: '12345678910',
        name: 'My product',
        description: 'product description',
        imageUrl: 'https://mywebsite.com/images/myproduct',
        unitPrice: 10.2,
        availability: 'InStock',
        categories: ['/Home'],
        tags: ['tag1','tag2'],
        brand: 'Brand',
        reviewCount: 1,
        rating: 2,
        ratingCount: 2,
        thumbnailUrl: 'https://mywebsite.com/images/thumb/myproduct',
        priority: 20,
        unitPriceOriginal: 10.2,
        unitPriceWithoutVAT: 8,
        discountedAmount: 0,
        discountedPercentage: 0,
        publishedAt: '2020-05-20T15:24:20Z',
        customField1: '',
        customField2: '',
        customField2: ''
    }]
};
connectif.managed.sendEvents([ // here my events if any ], { entityInfo, cart });

 

 

Congratulations!
You have reached the end of the lesson.

  

Any unresolved doubts?
Remember that you have at your disposal our Connectif specialists. To contact them, just open a ticket to Support by clicking the blue “Help” button in your dashboard.


Keep learning!

To take full advantage of your Connectif account, we recommend continuing with the following articles: