Create events

Events are the basis for event analysis on the Mini Program platform. You must create events before you can perform event analysis.

This topic describes how to create events.

Procedure

To create an event, take the following steps:

  1. Log on to the Mini Program platform.
  2. In the left navigation panel, choose Analytics > Custom Analysis.
  3. On the displayed Custom Analysis page, find the desired mini program.
  4. Click Events in the Action column. The Manage Event tab is displayed.
  5. On the Manage Event tab, click New Event.

image.png

Figure 1. Create an event

  1. On the New Event page, configure the parameters:

Parameter

Description

Example value

Event Name

The name of the event.

Follow a clear and consistent naming convention so analysts and developers can recognize it.

event_example1

Data Reporting Method

Specify the method in which data is collected and reported.

By default, By Self-Defined Actions is selected, which specifies that data are reported when the custom actions occur and conditions match.

By Self-Defined Actions

Action 1

Configure the action that triggers the event. An event can contain one or multiple actions. Each action is an independent rule that can trigger the event.

  • Trigger: Select the operation that triggers this action. Options:
    • click
    • enterPage
    • leavePage
    • pageLoad
    • pageUnload
    • switchTab
    • pullDownRefresh
    • launch
    • background
    • foreground
    • share
  • Report Type: Specify how often this action reports data:
    • Collect and Report Once: collects and reports data on a single action of a user.
    • Collect Multiple Times and Report Once: collects data on multiple actions of a user and reports the data once. In this case, you must specify whether to start collecting data or reporting the collected data when the action is triggered:
      • Start: starts to collect data.
      • Report: reports the collected data.

Note: The last action in an event must be reporting data.

  • Page: Enter the page path. You can find the page path via app.json files in the mini program source code of IDE (Mini Program Studio).
  • Element: The UI element to interact for the trigger to fire. Enter a class or ID, which must begin with a period (.) or a number sign (#), respectively. You can find the element via app.json files in mini program source code of IDE (Mini Program Studio).

Note: Page and Element are required only for specific operations.

  • Add fields. Fields are the metrics you want to analyze. You can define a name and assign attributes to this metric via Field Value and Field Type. You can click Field to add more fields.
    • Field Name: the name of a field.
    • Field Value: the value (variable) of the field.
    • Field Type:
      • Int: the integer type. Int is suitable for calculating amounts, where you can further define its maximum, minimum, count, sum, and average.
      • String: the string type. String is suitable for calculating the count of each occurrence.
    • Note: remarks of the field. You can describe fields in detail.

After configuring an action, you can click Action to add more actions to the event.

N/A

  1. After the event is configured, you can click one of the following buttons based on your business requirements:
    • Save: Stores your configuration as a draft.
    • Save & Test: Saves and opens test mode so you can validate that triggers fire as expected, selectors match, fields populate correctly, and Report Type behaves as intended. Use this before publishing.
    • Save & Publish: Publishes the event. Data collection starts immediately for users who meet the action conditions. You can also publish the event after the event is created. For more information, see Publish events.

Next steps