CategorySelection

From Barion Documentation
Jump to navigation Jump to search

categorySelection

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

Short description

Monitor users' interest in a product category.

Handle this event on any page in the webshop where the user can filter items for sale, for example by brand, theme, price range, common property, or other grouping.

Trigger

Button click on a product category page or a categor selection page.

Properties

Custom properties are supported.

Name Data type Description Required? Note
id string A unique identifier for the item or promotional material, such as a product ID, SKU, or promotion ID. yes
name string The full name associated with the item or promotional material, or the title of the visited page.
Make sure that you use the same name across Barion Pixel events for the same item or promotional material.

yes
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 content objects if the page displays multiple items for sale. no Don't include shipping or coupons.
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.
customerValue float Your self-defined metric that represents the business value of the given customer (based on for example their average basket value). 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. yes Step numbering starts at 1.

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

var categorySelectionProperties = {
    'id': 'books_scifi',
    'name': 'Sci-Fi Books',
    'category': 'Books',
    'contentType': 'Page',
    'customerValue': 150.0,
    'list': 'SearchPage',
    'positioning': '42'
}
// Use one of these to add the event listener to the button click (use only one):
// vanilla JS (if you don't use jQuery, that is, "$" isn't defined)
document.getElementById('select_category').addEventListener('click', function() {
    bp('track', 'categorySelection', categorySelectionProperties);
});
// jQuery (if you use jQuery, and "$" is available)
$("#select_category").click(function() {
    bp('track', 'categorySelection', categorySelectionProperties);
});