When users interact with the products, the site must notify the engine of this, partly in order for it to learn from the users, but also to provide statistics and metrics. You do this by creating a request to "CreateEvents" and provide a collection of event objects. There are generally 3 types of events (although more can be configured in custom implementations):
When a subsequent event is received by the engine, it performs a lookup in the table to find which previous search query is most probable to be the search query that led to the event. The engine does this using different heuristics such as what products were displayed, time between search and event, and HTTP data like Referrer and URL. This way, the engine can count the number of clicks, purchases etc for each product given a search query, both aggregated and personalized.
//click event (can be called on the product page)
$e = new Loop54_Event();
$e->type = "Click";
$e->entity = new Loop54_Entity("Product", "1");
$request = new Loop54_Request("CreateEvents");
$request->setValue("Events",array($e));
$response = Loop54_RequestHandling::getResponse("http://helloworld.54proxy.com", $request);
if (!$response->success)
{
echo $response->requestId; //log this
}
//addtocart event (call this when a customer adds a product to cart)
$e = new Loop54_Event();
$e->type = "AddToCart";
$e->entity = new Loop54_Entity("Product", "1");
$request = new Loop54_Request("CreateEvents");
$request->setValue("Events",array($e));
$response = Loop54_RequestHandling::getResponse("http://helloworld.54proxy.com", $request);
if (!$response->success)
{
echo $response->requestId; //log this
}
//purchase events (can be called when an order is processed, or on the "thank you" page)
$productLine = new stdClass();
$productLine->productId="1";
$productLine->quantity=5;
$products = array($productLine);
//create one event for each unique product in the order
$events = array();
foreach($products as $productLine)
{
$e = new Loop54_Event();
$e->type = "Purchase";
$e->orderId = "13t09j1g";
$e->quantity = $productLine->quantity;
$e->entity = new Loop54_Entity("Product", $productLine->productId); //1
$events[]=$e;
}
$request = new Loop54_Request("CreateEvents");
$request->setValue("Events",$events);
$response = Loop54_RequestHandling::getResponse("http://helloworld.54proxy.com", $request);
if (!$response->success)
{
echo $response->requestId; //log this
}
//click event (can be called on the product page)
POST to helloworld.54proxy.com/createevents
{
"UserId" : "helloworlduser",
"IP" : "127.0.0.1",
"Events" : [{
"Type" : "Click",
"Entity" : {
"EntityType" : "Product",
"ExternalId" : "1"
}
}
]
}
//addtocart event
POST to helloworld.54proxy.com/createevents
{
"UserId" : "helloworlduser",
"IP" : "127.0.0.1",
"Events" : [{
"Type" : "AddToCart",
"Entity" : {
"EntityType" : "Product",
"ExternalId" : "1"
}
}
]
}
//purchase events (can be called when an order is processed, or on the "thank you" page)
POST to helloworld.54proxy.com/createevents
{
"UserId" : "helloworlduser",
"IP" : "127.0.0.1",
"Events" : [{
"Type" : "Purchase",
"OrderId" : "13t09j1g",
"Quantity" : 5,
"Entity" : {
"EntityType" : "Product",
"ExternalId" : "1"
}
}
]
}
The API V2X-based Java Connector is no longer supported.
You can view code examples for the V3-based Connector at
https://github.com/LoopFiftyFour/Java-Connector
The API V2X-based .NET Connector is no longer supported.
You can view code examples for the V3-based Connector at
https://github.com/LoopFiftyFour/.NET-Connector
Product overview
Technology