Track Add to Cart
You can use the OnlineSales.ai pixel to track the products which are added to the cart by visitors. Tracked add to carts
is used to compute the cart sessions, cart abandoned and user-product affinity.
Requirements
The pixel's base code must already be installed on every page where you want to track add to carts.
Trigger
Add To Cart
event should be fired when a user adds a product to a cart.
JS API
All events are tracked by calling one of the library's function with a JSON object as it's parameters.
Following is a function call to track when a visitor has added a product
to the cart on your website.
List of all the standard events can be found here.
Object Properties of Products key
You can include the following predefined object properties with any events that support them. Format your parameter object data using JSON.
Complete list of object properties can be found here.
Example call of function with all the product properties
Tracking clicks on Buttons
Suppose you have an e-commerce website and your "Add to Cart" button does not navigate to a new page. You may want to activate an event when the button is clicked.
Fire Add To Cart
either on a new page load or on the click of an Add To Cart button. There are multiple ways to handle clicks on buttons. Here's an example adding an eventListener to a button.
There are many ways you can handle click events; just make sure to always call _osAdd2Cart
function after the click.
Last updated