Skip to main content

How to edit custom events in the MoEngage

Introduction​

This document will help you understand how to edit custom events in the MoEngage.

You can see the list of events sent to MoEngage here

Steps​

  1. Add this filter in the eventsHelper.js file in the your-theme/helpers/eventsHelper.js file.
import { appmaker } from '@appmaker-xyz/core';

function updateMoEngageEvents () {
appmaker.addFilter(
'moengageEventData',
'custom-events',
({ eventName, params, eventObject }) => {
console.log('eventName', eventName)
switch (eventName) {
case 'Product Viewed':
console.log('params', params); // params is an object object which contains the sending event attributes of the event.
console.log('eventObject', eventObject); // eventObject is an object that contains whole data for the event.
// example of updating the event params object using the eventObject
params['Product ID'] = eventObject?.product_sku?.value;
break;
case 'Add To Cart':
eventName = 'Add to Cart'; // example of updating the event name
params['Product ID'] = eventObject?.product_sku?.value;
break;
default:
break;
}
// sending the updated params and eventName
return {
eventName,
params,
};
},
);
}
export { updateMoEngageEvents }
  1. call this updateMoEngageEvents function in the your-theme/index.js file activate.

import { updateMoEngageEvents } from './helpers/eventsHelper';

export default function activate() {
// your other code
updateMoEngageEvents();
}