Custom Events

A Custom Event is a timestamped event that can be added to a Bundle within an ongoing session. This feature allows users to define and track specific actions or occurrences tailored to their application or business needs.

Here’s a sample code snippet demonstrating how to use the addCustomEvent method:

// Function to handle the custom event trigger
const session = YofiTelemetry.startSession(yourSessionConfig);
const AddCustomEvent = () => {
    const eventName = 'TargetElementCreated'; // Example event name
    const eventKey = 'input-field'; // Example event key (can be the input ID, for instance)
    const properties = { 'DataType': 'FirstName', 'Value': "YOUR VALUE" }; // Example custom properties

    session.addCustomEvent(eventName, eventKey, properties);
};

Parameters:

  1. eventName (string):

    • Description: The name used to track the custom event.

    • Constraints: The name should not exceed 50 characters.

    • Example: 'TargetElementCreated', 'ButtonClicked', 'FormSubmitted'.

    • Purpose: This parameter helps identify the custom event for tracking and analysis. It should be descriptive of the event’s purpose.

  2. eventKey (string, optional):

    • Description: A reference key used to help lookup specific events.

    • Constraints: The key should not exceed 50 characters.

    • Example: 'input-field', 'submit-button', 'checkout-form'.

    • Purpose: The eventKey is used to uniquely identify the event instance. This is helpful for distinguishing between multiple events of the same type, such as tracking interactions with different form fields or buttons.

  3. properties (object, optional):

    • Description: A collection of custom properties that correspond to the custom event.

    • Constraints:

      • Each key in the object should not exceed 50 characters.

      • Each value in the object should not exceed 50 characters.

    • Example: { 'DataType': 'FirstName', 'Value': 'John' }, { 'Action': 'Click', 'Location': 'HomePage' }.

    • Purpose: properties allow for additional contextual data to be associated with the custom event. This can provide more detailed insights into the event, such as the type of data or the action that triggered the event.

Last updated

Was this helpful?