Attraqt
Search…
XO
This page covers what you need to implement in order to integrate the the tracking library for XO.

Prerequisites

In order to be able to send events through the tracker for your XO integration you need to have the following information ready from server side in your front-end application.
Triggers
  • View Activity (view)
  • Add to Cart Activity (add to cart)
  • Purchase Activity (buy)
  • Click on Recommendation Activity (click on recommendation)
Variables
  • productid
  • quantity
  • orderId
  • widgetId
  • locale
  • price
  • quantity
  • currency
Usually the click-on-recommendation trigger is available after the integration of the XO Recommendation API

View

Views are sent whenever your customer navigates to a page, in this example it is when navigating to a product detail page (PDP). The properties needed to send a view event are:
  • action – this is where you specify what action/trigger you want. In this example it will be View
  • target.product – this is where you specify the product ID of the product being viewed
Action & target.product are mandatory
Any other extra detail can be added in the metadata object.
1
const viewActionOnProduct = {
2
"action":"view",
3
"target": {
4
"product":"PRODUCT ID"
5
},
6
"metadata": {}
7
}
8
xo.activity.send(viewActionOnProduct);
Copied!

Add to Cart

Add to cart should be sent when a user adds a product/item to their cart. This action is mostly used to calculate add to cart/basket conversion rates. This event should be sent for each product the user adds, and a specific quantity per product can be added in metadata.
The properties needed to send an add-to-cart event from a product detail page are:
  • action - add-to-cart
  • target.product - id of the product added to the cart
  • metadata - quantity and any other information wanted
1
const addToCartAction = {
2
"action":"add-to-cart",
3
"target": {
4
"product":"PRODUCT ID"
5
},
6
"metadata": {
7
"quantity": NUMERIC VALUE OF QUANTITY ADDED TO CARD
8
"variant": VARIANT ADDED TO CART
9
}
10
}
11
xo.activity.send(addToCartAction);
Copied!

Purchase

When a user makes a purchase, a purchase action should be sent for every item that is purchased (you can specify the quantity of the item purchased). Purchase events are used to calculate purchase conversion rates and revenue.
The properties needed to send a purchase event are as follows:
  • action - purchase
  • target.product - id of the product purchased
  • metadata – orderID and any other information wanted
  • quantity - you need to specify the quantity of the item purchased as an integer
  • price - you need to specify the price of the product purchased - in cents (i.e. no decimal spaces).
  • currency - the currency of the price, in **ISO 4217 format.
1
const purchaseAction = {
2
"action":"purchase",
3
"target": {
4
"product":"PRODUCT ID"
5
},
6
"metadata": {
7
"orderId": "ORDER ID",
8
"price": 0,
9
"quantity": 0,
10
"currency": "CURRENCY",
11
}
12
}
13
xo.activity.send(purchaseAction);
Copied!

Click on recommendation

When a user makes a purchase, a purchase action should be sent for every item that is purchased (you can specify the quantity of the item purchased). Purchase events are used to calculate purchase conversion rates and revenue.
The properties needed to send a purchase event are as follows:
  • action - click
  • target.product - id of the product clicked
  • metadata –
    • widgetId - The ID of XO Recommendation widhet
    • sourceId - The ID at the root the JSON API Response
1
const clickActionOnRecommendation = {
2
"action": "click",
3
"target": {
4
"product": "PRODUCT ID"
5
},
6
"sourceId": "RECOMMENDATION ID",
7
"metadata": {
8
"widgetId": "WIDGET ID"
9
}
10
}
11
xo.activity.send(clickActionOnRecommendation);
Copied!
Both widgetId & sourceId are mandatory
Last modified 21d ago