Hi all,
I need to calculate conversion rates (view/purchase) for each banner in my e-commerce site. I have 3 documents, assume you are surfing on an ecommerce site there are lots of products and banners. When u see a banner, banner_view event is saved to elasticsearch. On banner_view event we have user_id ( who saw the banner ) and banner_id
---------------------------
banner_view
---------------------------
{
"user-id": "id-1234",
"banner-id": "banner_x",
}
Actually from the system point of view I know which banner is related to which products. Say I have a set of documents showing this relation;
---------------------------
banner-product-relation
---------------------------
{
"banner-id": "banner_x",
"product_ids": [
"product_1",
"product_8"
]
}
{
"banner-id": "banner_y",
"product_ids": [
"product_10",
"product_11",
"product_12"
]
}
Assume during your session, you decided to buy some products. When u buy products checkout_completed event is triggered ans saved in elasticsearch.
---------------------------
checkout_completed
---------------------------
{
"user-id": "id-1234",
"products" : [
{
product_id: "product_1",
price: "123"
},
{
product_id: "product_2",
price: "253"
},
{
product_id: "product_3",
price: "62"
}
]
}
As u see in samples user (id_1234) first saw a banner (banner_x) then bought a product (product_1) which is related to banner. In order to calculate conversion for each banner I need something like that;
user-id | banner_id | impression_count | purchase_count
id-1234 | banner_x | 1 | 1
How can I calculate such an aggregation with elasticsearch,
please feel free to advice model changes also, I can change model of documents or create new documents.
regards.