Skip to main content

How to add an analytics event

​1. Import the analytics

import { analytics } from "@appmaker-xyz/core";

​ 2. Add the following code to the place where you want to track the event ​

analytics.track(
"event_name",
{
// event properties (optional)
},
{
// event context (optional)
}
);

​ Example: ​

analytics.track(
"discount_banner_click",
{
discount_percentage: "50 %",
},
{
cart: {
total: 100,
currency: "EUR",
lineItems: [
{
name: "Product 1",
quantity: 1,
price: 50,
currency: "EUR",
},
{
name: "Product 2",
quantity: 1,
price: 50,
currency: "EUR",
},
]
},
// other context properties
}
);