RemoveFromCart

From Barion Documentation
Jump to navigation Jump to search

removeFromCart

Required event. Handling this event on your Barion shop's screens is required as part of a Barion Full Pixel implementation.

Short description

The event keeps track of when the user changes their mind about selecting a product for purchase, and contributes to the monitoring of user interest in products

Trigger

A button click that results in an item being removed from the list of items selected for purchase.

Trigger this even both for an explicit "remove from cart" user action, as well as when the user cancels the ongoing purchase.

Properties

Custom properties are supported.

Name Data type Description Required? Note
contentType One of the following string options: "Page", "Product", "Article", "Promotion", "Banner", "Misc" The type of page that triggered the event. yes In case this is an item listing page, pass "Product". Otherwise, select the option that best matches the type of page. See the event's list property also.
currency string (ISO 4217 currency code) The currency that the associated item's price is listed in. yes Required if "contentType": "Product"
id string A unique identifier for the item associated with the event. yes
name string The full name associated with the item associated with the event.
Make sure that you use the same name across Barion Pixel events for the same item or promotional material.
yes
quantity float The quantity that is displayed on the page for the item on sale. yes Required if "contentType": "Product"
totalItemPrice float The total price of the item or items added to the cart, in the specified currency. yes
unit string The displayed item's unit (e.g. piece, set, liter). yes Required if "contentType": "Product"
unitPrice float The price of a single unit of the item for sale, in the currency property. yes Required if "contentType": "Product"
brand string The item's brand. no
category string -separated subcategory chain (e.g. "clothes|shoes|winter") or the single category (e.g. "winter shoes") of the item for sale. no
contents array An array of [[../05-barion-pixel-reference/00-pixel-event-reference#content|content objects]] if the page displays multiple items for sale. no Don't include shipping or coupons.
coupon string The coupon code used when the user added the item to the cart. no
creative string The associated promotion's name or description, such as an advertising slogan or the name of the promotional image file. no
customerValue float Your self-defined metric that represents the business value of the given customer (based on for example their average basket value). no
ean string The item's International Article Number (EAN). no
list string Select the function of the visited page from one of the following string options: "HomePage", "SearchPage", "ProductPage", "Recommendation", "ComparisonPage", "BasketPage", "Checkout", "Misc" no
positioning string The item's position in a list or collection (e.g. 2) or the position of its promotion on the page (e.g. banner_slot_1). no
step integer The order that the visited page is displayed in within a multi-step checkout process, if applicable. no Step numbering starts at 1.
variant string The variant of the item on sale that distinguishes it from other similar items (such as color, material, or time and date). no

Barion Pixel throws the following errors in your browser console if a required property is missing or is passed in the wrong format:

"Barion Pixel: Format of PROP_NAME is invalid in EVENT_NAME"

"Barion Pixel: The PROP_NAME parameter of the EVENT_NAME event cannot be empty"

Sample implementation

// sample product data for single items
var removeFromCartProperties = {
    'contentType': 'Product',
    'currency': 'HUF',
    'id': 'item_42',
    'name': "Hitchhikers' Guide to the Galaxy, hardcover, ISBN: 9780575115347",
    'quantity': 10.0,
    'totalItemPrice': 49900.0,
    'unit': 'pcs.',
    'unitPrice': 4990.0,
    'brand': 'Gollancz',
    'category': 'books|hardcover|scifi, books|hardcover|comedy',
    'coupon': '43763436874',
    'creative': 'upsell_promo_42',
    'customerValue': 150.0,
    'ean': '9780575115347',
    'list': 'BasketPage',
    'positioning': '3',
    'variant': 'hardcover'
}
// sample product data for bundled items
var removeFromCartProperties = {
    'contentType': 'Product',
    'currency': 'HUF',
    'id': 'item_42pack',
    'name': "Hitchhikers' Guide to the Galaxy, hardcover, ISBN: 9780575115347",
    'quantity': 10.0,
    'totalItemPrice': 150000.0,
    'unit': 'pcs.',
    'unitPrice': 15000.0,
    'brand': 'Gollancz',
    'category': 'books|hardcover|scifi, books|hardcover|comedy',
    'contents': [{
        'contentType': 'Product',
        'currency': 'HUF',
        'id': 'item_42',
        'name': "Hitchhikers' Guide to the Galaxy, hardcover, ISBN: 9780575115347",
        'quantity': 3.0,
        'totalItemPrice': 7500.0,
        'unit': 'pcs',
        'unitPrice': 2500.0,
        'brand': 'Gollancz',
        'category': 'books|hardcover|scifi, books|hardcover|comedy',
        'description': 'The Hitchhikers Guide to the Galaxy is a comedy science fiction series created by Douglas Adams.',
        'ean': '9780575115347',
        'imageUrl': 'https://images-na.ssl-images-amazon.com/images/I/51MzUz8rQcL._SX305_BO1,204,203,200_.jpg',
        'variant': 'hardcover'
        },
        {
        'contentType': 'Product',
        'currency': 'USD',
        'id': 'item_42en',
        'name': "Hitchhikers' Guide to the Galaxy, hardcover, ISBN: 9780575115347",
        'quantity': 3.0,
        'totalItemPrice': 25935,
        'unit': 'pcs',
        'unitPrice': 8645,
        'brand': 'Gollancz',
        'category': 'books|hardcover|scifi, books|hardcover|comedy',
        'description': 'The Hitchhikers Guide to the Galaxy is a comedy science fiction series created by Douglas Adams.',
        'ean': '9780575115347',
        'imageUrl': 'https://images-na.ssl-images-amazon.com/images/I/51MzUz8rQcL._SX305_BO1,204,203,200_.jpg',
        'variant': 'hardcover'
        }],
    'coupon': '43763436874',
    'creative': 'upsell_promo_42',
    'customerValue': 150.0,
    'ean': '9780575115347',
    'list': 'BasketPage',
    'positioning': '3',
    'variant': 'hardcover'
}
// Use one of these to add the event listener to the button click (use only one):
// vanilla JS (if you don't use jQuery)
document.getElementById('remove_button').addEventListener('click', function() {
    bp('track', 'removeFromCart', removeFromCartProperties);
});
// jQuery
$("#remove_button").click(function() {
    bp('track', 'removeFromCart', removeFromCartProperties);
});