Engage.event(type, eventData[, extensionData])
The event()
function sends one of the following:
-
A custom event with custom data of your choice.
Here's an example of how to use the event()
function to send an ADD event. The eventData
object must contain all the required attributes for the event type, in this example, for an ADD event.
import { engage } from "./engage.js";
// ...
const handleClickAddEvent = async () => {
const eventData = {
channel: "WEB",
currency: "EUR",
pointOfSale: "myretailsite/ireland",
language: "EN",
page: "products",
product: {
name: "GHT 84 Lace Sneaker",
type: "FOOTWEAR",
item_id: "SHOES_8475GHT",
productId: "example_product_id",
referenceId: "MA-490094",
orderedAt: new Date().toISOString(),
quantity: 1,
price: 7.99,
currency: "EUR",
originalPrice: 7.79,
originalCurrencyCode: "USD"
}
};
const extensionData = {
customKey: "customValue"
};
await engage.event("ADD", eventData, extensionData);
};
Here's an example of how to use the event()
function to send a CONFIRM event. The eventData
object must contain all the required attributes for the event type, in this example, for a CONFIRM event.
import { engage } from "./engage.js";
// ...
const handleClickConfirmEvent = async () => {
const eventData = {
channel: "WEB",
currency: "EUR",
pointOfSale: "myretailsite/ireland",
language: "EN",
page: "checkout",
product: [
{ item_id: "SHOES_8475GHT" }
]
};
const extensionData = {
customKey: "customValue"
};
await engage.event("CONFIRM", eventData, extensionData);
};
Here's an example of how to use the event()
function to send a CHECKOUT event. The eventData
object must contain all the required attributes for the event type, in this example, for a CHECKOUT event.
import { engage } from "./engage.js";
// ...
const handleClickCheckoutEvent = async () => {
const eventData = {
channel: "WEB",
currency: "EUR",
pointOfSale: "myretailsite/ireland",
language: "EN",
page: "home",
reference_id: "MA-490094",
status: "PURCHASED"
};
const extensionData = {
customKey: "customValue"
};
await engage.event("CHECKOUT", eventData, extensionData);
};
Here's an example of how to use the event()
function to send a PAYMENT event. The eventData
object must contain all the required attributes for the event type, in this example, for a PAYMENT event.
import { engage } from "./engage.js";
// ...
const handleClickPaymentEvent = async () => {
const eventData = {
channel: "WEB",
currency: "EUR",
pointOfSale: "myretailsite/ireland",
language: "EN",
page: "home",
paymentType: "voucher"
};
const extensionData = {
customKey: "customValue"
};
await engage.event("PAYMENT", eventData, extensionData);
};
Here's an example of how to use the event()
function to send a CLEAR_CART event. The eventData
object must contain all the required attributes for the event type, in this example, for a CLEAR_CART event.
import { engage } from "./engage.js";
// ...
const handleClickClearCartEvent = async () => {
const eventData = {
channel: "WEB",
currency: "EUR",
pointOfSale: "myretailsite/ireland",
language: "EN",
page: "home"
};
const extensionData = {
customKey: "customValue"
};
await engage.event("CLEAR_CART", eventData, extensionData);
};
Here's an example of how to use the event()
function to send a SEARCH event. The eventData
object must contain all the required attributes for the event type, in this example, for a SEARCH event.
import { engage } from "./engage.js";
// ...
const handleSearchEvent = async () => {
const eventData = {
channel: "WEB",
currency: "EUR",
pointOfSale: "myretailsite/ireland",
language: "EN",
page: "search result page",
"product_name": "airSupport",
"product_type": "RUNNERS"
};
const extensionData = {
customKey: "customValue"
};
await engage.event("SEARCH", eventData, extensionData);
};
Here's an example of how to use the event()
function to send a custom event called myretailsite:CLICKED_POPUP
. eventData
contains all the required attributes for the event data object. extensionData
contains the custom data.
import { engage } from "./engage.js";
// ...
const handleClick = async () => {
const eventData = {
channel: "WEB",
currency: "EUR",
pointOfSale: "myretailsite/ireland",
language: "EN",
page: "home"
};
const extensionData = {
customKey: "customValue"
};
await engage.event("myretailsite:CLICKED_POPUP", eventData, extensionData);
};