Events

Events

The Loop54 engine learns from user interactions and those interactions are sent to the engine as events. All implementations must send the required events or the service will not work as intended. In addition to the required events it is also possible to send custom events.

Required Events

The set of events that must be sent are the following:

  • Click - a user clicks on a product in a search result

  • Add to cart - a user adds a product to the shopping cart

  • Purchase - a user completes a the purchase of a product

Sending an Event

This example shows how to send the three required events. The Loop54 connector will automatically keep track of the user ID and use that in the call. If there is a need to send a custom user ID, see the Events with Custom User ID example below.

// Code examples

//click event (can be called on the product page)
Entity clickedEntity = new Entity("Product", productId);
_loop54Client.CreateEvents(new CreateEventsRequest(new ClickEvent(clickedEntity)));

//addtocart event (call this when a customer adds a product to cart)
Entity addToCartEntity = new Entity("Product", productId);
_loop54Client.CreateEvents(new CreateEventsRequest(new AddToCartEvent(addToCartEntity)));

//purchase events (can be called when an order is processed, or on the "thank you" page)
Entity purchasedEntity = new Entity("Product", productId);
_loop54Client.CreateEvents(new CreateEventsRequest(new PurchaseEvent(purchasedEntity)
{
    OrderId = "13t09j1g", //Optional but recommended
    Quantity = 5, //Optional
    Revenue = 249d //Optional
}
));

C# source code on Github: EventTrackingController.cs

Events with Custom User ID

This is how to send events using a custom user ID.

// How it works

//click event with a custom user ID
_loop54Client.CreateEvents(new CreateEventsRequest(new ClickEvent(clickedEntity)).Wrap(new UserMetaData("testUserID")));

C# source code on Github: EventTrackingController.cs

Last updated