Store Page Hybrid Log Event
We have implemented several events in our current store page for CleverTap, Facebook, and Google.
CleverTap
Trigger: when loaded restaurant page Event Name: Restaurant Viewed Event Property:
| property name | property value | notes |
|---|---|---|
| id | restaurant id | |
| packageTypes | type_code | array to string separated by comma |
| primaryCuisine | cuisine | |
| primaryLocation | location | |
| locations | locations | array to string separated by comma |
| rating | reviews_score | |
| hasVideo | videos | if size > 0 = true |
| name | restaurant name | |
| availability | availability | |
| canonical_link | canonical_link | |
| restaurant_name_en | restaurant_name_en | |
| restaurant_name_th | restaurant_name_th | |
| branchId | branch_id | (if any, not mandatory) |
| myFavorite | favorited | Verification required: uncertain if this property is still active. |
Updated Data for Netcore:
| property name | property value | notes |
|---|---|---|
| id | restaurant id | |
| package_types | type_code | array to string separated by comma |
| primary_cuisine_id | 13 | to string |
| primary_cuisine_name | cuisine | |
| primary_location_id | 12 | to string |
| primary_location_name | location | |
| location | locations | array to string separated by comma |
| rating | reviews_score | float (e.g. 4.8)has_video |
| has_video | yes | if size > 0 = “yes” else “no” |
| name | restaurant name | |
| availability | availability | |
| canonical_link | canonical_link | |
| restaurant_name_en | restaurant_name_en | |
| restaurant_name_th | restaurant_name_th | |
| branch_id | branch_id | (if any convert to “string”) |
| image_url | image_cover_url.large | |
| url | caonical_link | |
| my_favorite | favorited | if true = “yes” else “no” |
Trigger: when click book button at the package Event Name: Initiated to Book Event Property:
| property name | property value | notes |
|---|---|---|
| restaurant_id | restaurant id | |
| restaurant_name | name | |
| canonical_link | canonical_link | |
| restaurant_name_en | restaurant_name_en | |
| restaurant_name_th | restaurant_name_th |
Hybrid Event: onCleverTapPushEvent Response:
{
"event_name": "Initiated to Book", // event name
"data": [ // event property
{
"name": "restaurant_id",
"value": "997"
},
{
"name": "restaurant_name",
"value": "Cafe Calire"
},
{
"name": "cuisine",
"value": "Pizza"
},......
]
}
in Android:
HashMap<String, Object> map = new HashMap<>();
for (int i = 0; i < dataList.size(); i++) {
String name = data.get(i).getName();
String value = data.get(i).getValue();
map.put(name, value);
}
clevertapDefaultInstance.pushEvent(event_name, map);
in iOS:
let props = [
"restaurant_id": "997",
"restaurant_name": "Cafe Claire",
"cuisine": "Pizza",
"name": "value"
] as [String : Any]
CleverTap.sharedInstance()?.recordEvent(event_name, withProps: props)
TODO: Implement Swift loop mapping from data array into [String: Any] before calling CleverTap API.
Google Analytics
Trigger: when loaded restaurant page Event Name: view_item Event Property:
| property name | property value | notes |
|---|---|---|
| currency | price_and_pricing_type.currency | string |
| value | price_and_pricing_type.amount | integer |
| items | item_id, item_name, category |
Trigger: when click book button at the package Event Name: add_to_cart Event Property:
| property name | property value | notes |
|---|---|---|
| currency | currency | string |
| value | lowest price from attributes rules | integer |
| items | item_id, item_name, category |
More or less the data is similar to above, but we need to change value to package lowest price instead of restaurant-level data.
Google Analytics implementation is more complex due to mixed data types, unlike CleverTap’s string-only approach. To make it correct, we send separated params with explicit types.
Hybrid Event: onGooglePushEvent
Response:
{
"event_name": "view_item",
"data": [
{
"name": "currency",
"type": "string",
"string_value": "THB",
"number_value": null,
"items": null
},
{
"name": "value",
"type": "double",
"string_value": null,
"number_value": 599,
"items": null
},
{
"name": "items",
"type": "array",
"string_value": null,
"number_value": 599,
"items": [
{
"name": "item_id",
"value": "997"
},
{
"name": "item_name",
"value": "Cafe Claire"
},
{
"name": "category",
"value": "Pizza"
}
]
}
]
}
in Android will be like this:
Bundle bundle = new Bundle();
bundle.putString("currency", "THB");
bundle.putDouble("value", 599);
Bundle items = new Bundle();
items.putString("item_id", "997");
items.putString("item_name", "Cafe Claire");
items.putString("category", "Pizza");
bundle.putParcelableArray("items", new Parcelable[]{items});
mFirebaseAnalytics.logEvent(event_name, bundle);
in iOS will be like this:
var productDetails: [String: Any] = [
"currency": "THB",
"value": 599
]
var items: [String: Any] = [
"item_id": "997",
"item_name": "Cafe Claire",
"category": "Pizza"
]
// Add items array
productDetails["items"] = [items]
// Log view item event
Analytics.logEvent(event_name, parameters: productDetails)
Trigger: when click book button at the package Event Name: add_to_cart Event Property:
| property name | property value | notes |
|---|---|---|
| currency | currency | string |
| value | lowest price from attributes rules | integer |
| items | item_id, item_name, category |
More or less the data is similar like above, only need to change value with package lowest price instead from restaurant data.
Facebook Event
Trigger: when loaded restaurant page Event Name: fb_mobile_content_view Event Property:
| property name | property value | notes |
|---|---|---|
| fb_content | restaurant id | string |
| fb_content_id | restaurant id | string |
| fb_content_type | product | string |
| fb_currency | price_and_pricing_type.currency | string |
Trigger: when click book button at the package Event Name: fb_mobile_add_to_cart Event Property:
| property name | property value | notes |
|---|---|---|
| fb_content | restaurant id | string |
| fb_content_id | restaurant id | string |
| fb_content_type | product | string |
| fb_currency | price_and_pricing_type.currency | string |
Facebook event set price separately with params. So, we also need to setup that as separate value. Hybrid Event: onFacebookPushEvent Response:
{
"event_name": "fb_mobile_content_view",
"price": 599,
"data": [
{
"name": "fb_content",
"value": "997"
},
{
"name": "fb_content_id",
"value": "997"
},
{
"name": "fb_content_type",
"value": "product"
},
{
"name": "fb_currency",
"value": "THB"
}
]
}
in Android:
Bundle params = new Bundle();
// simplify with array
for (int i = 0; i < dataList.size(); i++) {
String name = data.get(i).getName();
String value = data.get(i).getValue();
params.putString(name, value);
}
// more or less will looks like this:
params.putString("fb_content", "997");
params.putString("fb_content_id", "997");
params.putString("fb_content_type", "product");
params.putString("fb_currency", "THB");
logger.logEvent(event_name, price, params);
in iOS: Use the official Facebook iOS App Events API with a parameter dictionary and value argument.
let parameters: [AppEvents.ParameterName: Any] = [
.init("fb_content"): "997",
.init("fb_content_id"): "997",
.init("fb_content_type"): "product",
.init("fb_currency"): "THB"
]
AppEvents.shared.logEvent(.init(event_name), valueToSum: 599, parameters: parameters)
https://developers.facebook.com/docs/app-events/best-practices/ecom-and-retail