track

This method helps to track events, which could result in actions such as an in-app message being displayed.

Syntax

MCReactModule.track(event);

Parameters

Parameter Type Description
event CustomEvent, EngagementEvent, IdentityEvent, SystemEvent, CartEvent, OrderEvent, or CatalogObjectEvent The event to track.

Returns

  • void - No return value.

Example

import { MCReactModule } from "react-native-marketingcloudsdk";

const trackPurchaseEvent = () => {
  try {
    const purchaseEvent = {
      name: "Purchase",
      attributes: {
        amount: 29.99,
        currency: "USD",
        productId: "prod123",
      },
    };
    MCReactModule.track(purchaseEvent);
    console.log("Purchase event tracked");
  } catch (error) {
    console.error("Error tracking event:", error);
  }
};

See Also