The AJAX event for products added or removed is used to indicate changes to the cart using AJAX, without the need to reload the page. This way, you can ensure that Connectif is immediately notified when products are added or removed from the shopping cart and optimize the tracking of changes to the cart.
How to use it
The AJAX cart event is used to report on a user's shopping cart at a specific time. It notifies you, via JavaScript, when a user accesses a product detail page by using the function connectif.managed.sendEvents, making the following call to Connectif:
connectif.managed.sendEvents([], { cart: cartObject });
Other considerations
It is important to also send the notification when the cart is emptied, so that it does not end up being marked as abandoned.
Example
The notification will look like this (not all data is required):
connectif.managed.sendEvents([], { 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: '' } ] } });
Keep learning!
To make the most of your Connectif account, we recommend reading these articles next:
- Add Connectif JavaScript to your website, to insert the code and start collecting information about visits to your page.
- Tag integration, to discover all the notifications that you can send from your eCommerce to Connectif and how they work.
- Integration with Connectif via API, to synchronize contacts, products, purchases and coupons.
- Check the integration with your ecommerce, so you can be confident that your data is syncing correctly with your Connectif account.