InitiateCheckout

From Barion Documentation
Revision as of 11:29, 22 May 2024 by [email protected] (talk | contribs) (created page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

InitiateCheckout

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 monitors the items that a user has already purchased to inform the choice of ads that are served to the user.

Trigger

A button click that starts the checkout process.

Fire this event when the user starts the checkout process for the items currently in their cart.

Note that the separate initiatePurchase Barion Pixel event for when the user actually confirms the purchase, typically after first initiating checkout.

Properties

Custom properties are supported.

Name Data type Description Required? Note
contents array An array of content objects if the page displays multiple items for sale. no Don't include shipping or coupons.
currency string (ISO 4217 currency code) The currency that the associated item's price is listed in. yes Required if "contentType": "Product"
revenue float The total revenue associated with the transaction in the specified currency. yes Includes costs such as shipping, tax, or discounts.
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.
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.
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
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
opt string Additional information about the purchase. no
orderNumber string The unique identifier of the purchase. 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
shipping float The shipping costs associated with the purchase, in the specified currency. no
shippingAddress An address object. The shipping address associated with the order. no
tax float The tax to be paid for the items in the order, in the currency specified. 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

Physical item (book) sample

var initiateCheckoutProperties = {
    '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'
        }],
    'currency': 'HUF',
    'revenue': 17500.0,
    'step': 1,
    'contentType': 'Product',
    'coupon': '43763436874',
    'creative': 'preselected_cart_01',
    'customerValue': 150.0,
    'list': 'Checkout',
    'opt': 'To postal office, no street address',
    'orderNumber': '852',
    'positioning': '1',
    'shipping': 2500.0,
    'shippingAddress': {
        'city': 'Budapest',
        'country': 'HU',
        'deliveryMethod': 'DHL',
        'fullName': 'John Doe',
        'phone': '+36 1 1111 111',
        'region': 'HU-BU',
        'street': 'Műegyetem rkpt. 3.',
        'street2': '2. porta',
        'zipCode': '1111'
    },
    'tax': 0.0
}
// 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('checkout_button').addEventListener('click', function() {
    bp('track', 'initiateCheckout', initiateCheckoutProperties);
});
// jQuery
$("#checkout_button").click(function() {
    bp('track', 'initiateCheckout', initiateCheckoutProperties);
});

Virtual product (concert ticket) sample

var initiateCheckoutProperties = {
    'contents': [{
        'contentType': 'Product',
        'currency': 'GBP',
        'id': 'metalica_12',
        'name': 'Metallica',
        'quantity': 2.0,
        'totalItemPrice': 600.0,
        'unit': 'pcs',
        'unitPrice': 300.0,
        'category': 'Pop|Metal',
        'description': 'Early Bird',
        'ean': '9780575115347',
        'imageUrl': 'https://www.revolvermag.com/sites/default/files/styles/image_954_x_537/public/media/images/article/metallicapr.jpg',
        'variant': '2019.06.08 20:00|Slane Castle'
        },
        {
        'contentType': 'Product',
        'currency': 'GBP',
        'id': 'snoop_dog_2019',
        'name': "Snoop Dog",
        'quantity': 3.0,
        'totalItemPrice': 1500.0,
        'unit': 'pcs',
        'unitPrice': 500,
        'category': 'Rap',
        'description': 'Early Bird',
        'ean': '9780575115347',
        'imageUrl': 'https://cdn1.thr.com/sites/default/files/2012/08/snoop-dogg-pr-08-p.jpg',
        'variant': '2019.04.02 23:00|Wembley'
        }],
    'currency': 'GBP',
    'revenue': 2100.0,
    'step': 1,
    'contentType': 'Product',
    'coupon': '43763436874',
    'creative': 'preselected_cart_01',
    'customerValue': 150.0,
    'list': 'Checkout',
    'opt': 'To postal office, no street address',
    'orderNumber': '852',
    'positioning': '1',
    'shipping': 2500.0,
    'shippingAddress': {
        'city': 'Budapest',
        'country': 'HU',
        'deliveryMethod': 'DHL',
        'fullName': 'John Doe',
        'phone': '+36 1 1111 111',
        'region': 'HU-BU',
        'street': 'Műegyetem rkpt. 3.',
        'street2': '2. porta',
        'zipCode': '1111'
    },
    'tax': 0.0
}
// 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('checkout_button').addEventListener('click', function() {
    bp('track', 'initiateCheckout', initiateCheckoutProperties);
});
// jQuery
$("#checkout_button").click(function() {
    bp('track', 'initiateCheckout', initiateCheckoutProperties);
});