Pushing Events to Crobox: Javascript API Snippets
The next step in order to successfully integrate Crobox to your website is to implement event tracking by implementing the Javascript API snippets listed in this document.
Introduction
By pushing events to Crobox using custom code snippets per page you can easily integrate the various event tracking needed for Crobox to be able to provide rich Product insights. By connecting those events the various metrics and real-time product information will be available.
Pageviews
On each pageview an event should be sent to Crobox using the crobox.pageview(data: object, force?: boolean)
API.
The first argument is an object with properties that are different per pagetype.
The second argument is a boolean which only should be set to true
when you are using an SPI interface and you want to force a new pageview. Normally multiple pageview calls without refreshing the browser will augment each other, by using force: true
it will register a new pageview instead.
Page types
Crobox uses page types to categorize types of pages together, built-in system ones are:
index (Home Page)
overview (Product Lister Page)
detail (Product Detail Page)
cart (Cart Page)
checkout (Checkout Page)
complete (Complete / Confirmation page)
search (Search Result page)
other (Fallback)
Properties available per page type
Different properties can be sent per page type in the pageview event. For example the checkout pages can have a step
property where the overview pages can have a list of all product-ids currently available on that lister page. The various properties are specified for each individual page-type below.
All pages
These properties are required on all pageview events.
Code example
Overview pages
Product Lister pages normally contain a list of products. By specifiying the ordered list products-ids that are shown Crobox can track which products have been viewed.
Code example
Detail pages
Product Detail Pages are centered around a single product. By sending that product-id to Crobox it can be used for example to give detailed insights about metrics like Look-to-Book ratio or Add-to-Cart rate.
Code example
Cart pages
It is important to register the product-id and quantity of the shopping-cart on cart pages. This helps Crobox to properly identify which products are added, or removed from cart.
Code example
Checkout pages
Checkout pages can have multiple steps. By optionaly identifying each step you can get deeper insights of checkout behavior.
Code example
Complete pages
Complete pages are the most important event to push to Crobox correctly, since they are used to register which products have been bought and if the visitor has converted.
Code example
Search pages
Search pages can have an optional search term that was used to get to the search-results.
Code example
Actions
Numerous actions are happening on pages at the same time. In order for Crobox to be able to provide more advanced analytics about products it is possible to set up tracking for other actions, as well. Two such actions are built-in, namely:
Impression click action
Execute this code when on a product lister page a specific product is clicked. This is so Crobox can register which products are most commonly clicked.
Add-to-cart action
Execute this code when a product is added to the cart.
Custom actions, for example add-to-favorites
It is also possible to set up tracking for custom actions, for example when you want to track the number of times users have added a specific product to their favorites. The following logic can be used for such cases:
Event system
There is an Events API available that can be used to communicate with the third-parties to have a stable connection between the Crobox Platform and the integrating party. This could be used to integrate with third-party analytics or:
Register a new event-listener on the event system
crobox.on(event, callback)
crobox.on(event, callback)
Use this method to register a new event-listener on the event system.
De-register an existing event-listener on the event system
crobox.off(event, callback)
crobox.off(event, callback)
Use this method to de-register an existing event-listener on the event system. Note: for this, you do need to have a reference to the existing callback.
Fire a new event in the event system
crobox.emit(event, args...)
crobox.emit(event, args...)
Use this method to fire a new event in the event system.
Last updated