Before you create automated marketing tasks that are triggered by behavioral events, you must define events and implement event reporting. This topic describes how to customize, manage, and report events.
There are two types of events:
Custom events
You must define custom events and implement event reporting.
You can report custom events from the following channels:
Your first-party applications: apps, mini programs, and web pages (including H5 pages)
Third-party system applications
For example, you can report a user action, such as clicking a button or purchasing a product on your H5 page, as an event to Quick Audience.
Two methods are available for reporting events from different channels:
For apps, mini programs, web pages, and third-party systems: You can add a script to your first-party or third-party system. The script converts logs collected by the application into a standard Message Queue (MQ) event model and reports the events to Quick Audience. For more information, see Report events.
For apps, mini programs, and web pages: Quick Audience can integrate with Quick Tracking, an Alibaba Cloud user behavior insight and analysis platform. Your first-party applications can use the software development kit (SDK) provided by Quick Tracking to collect and report events. For more information, see What is Quick Tracking and Data ingestion APIs.
System default events
The system provides predefined default events for some feature modules, such as Social Interaction. The system automatically reports these events through integration with the corresponding feature modules.
NoteTo use Social Interaction events, you must purchase the Social Interaction feature package. The Social Interaction module must be attached to a WeChat Official Account, and this account must also be attached to the User Marketing module.
Organization administrators, workspace administrators, and members with the "Social Interaction - Customer Operations" or "Social Interaction - Official Account Operations" roles can use Social Interaction events.
Custom events
Procedure:
Go to the event list page. To do this, choose Workspace > Configuration Management > Automated Marketing > Event Management.

In the upper-right corner, click New Event. The New Event dialog box appears.
In the dialog box, configure the following parameters:

Parameter
Description
Application Type
Select the application type of the event reporting channel. The following types are supported:
App
Mini Program
Web: Web pages, including H5 pages
Third-party System
Is collection enabled for Quick Tracking?
For event reporting channels that are not third-party systems, select whether data is collected by Quick Tracking.
Platform Type
For an app or mini program that uses Quick Tracking for data collection, select the platform type that you specified for the channel when you configured it in Data ingestion APIs.
Channel Name
For channels that do not use Quick Tracking for data collection, select a channel name from the drop-down list.
You can click Add Channel Name in the drop-down list or Edit Channel Name to the right of the list to create or edit a channel name. For more information, see the Add channel name child step below.
For channels that use Quick Tracking for data collection, select the channel name that you set when you configured the channel in Data ingestion APIs.
Event Code
Enter or select an event code. The instrumentation developer defines the event code to uniquely identify an event.
Event Name
Enter an event name.
Event Property
When you add an event, you can use event properties to store additional information. For example, if the event is "Successfully purchased a wealth management product", you can add "Wealth management product type" as an event property.
Click Add Event Property to add a new event property row.
Click Remove to remove the corresponding event property.
Property Type
For channels that use Quick Tracking for data collection, select the type of event property:
Event Property: This is the default selection. The property is used only for the current event.
Global Property: If you select this option, the property is automatically added to all events in the same channel after it is set once. For example, all events in the same channel can carry the logged-on user ID.
For channels that do not use Quick Tracking for data collection, this option is not available. All properties are used only for the current event. There are no global properties.
Event Property Data Type
Select the data type for the event property. Valid values are Text and Numeric.
Event Extension Property ID
Enter the event extension property ID.
The instrumentation developer defines the property ID to store supplementary information for the collected event. For example, if the app collection event is "Purchase item", the property name can be "Item ID", and the property ID can be "item_id".
Event Extension Property Name
Enter the event extension property name.
Add channel name: For channels that do not use Quick Tracking for data collection, if you click Add Channel Name, enter the Channel Name and APP_KEY in the dialog box that appears. The APP_KEY uniquely identifies a channel and is typically the appkey defined on the data collection platform.

Edit channel name: For channels that do not use Quick Tracking for data collection, if you click Edit Channel Name, a dialog box like the one shown in the following figure appears.
Click Edit to modify the channel name.
If there are no events under the channel, click Delete to delete the channel record.

Click Confirm to create the event.
Manage events
The event list is shown in the following figure.
The list displays three types of events:
Collected by Quick Tracking: Custom events for which data is collected by Quick Tracking.
Custom Event: Custom events for which data is not collected by Quick Tracking.
System Default Event: For system default events, the channel name indicates the integrated feature module, such as Social Interaction.
You can perform the following management operations on events:
Search: In the upper-right corner of the page, you can search for events by name or event code.
Filter: In the upper-right corner of the page, you can filter events by a specific channel.
Edit: Click Edit next to a custom event to modify it. You can change the event name, event extension property names, and add event properties. You cannot modify other parameters or delete event properties. The procedure is the same as creating an event.
Delete: Click Delete next to a custom event to delete it. You can only delete events that are not used by any automated marketing tasks.
Report events
If you do not use Quick Tracking to collect data, developers of your first-party or third-party systems must write a script. The script converts logs collected by the application into a standard Message Queue (MQ) event model and reports the events to Quick Audience. The following figure illustrates the process of reporting event and user information.
To report events, you must install the Java SDK provided by Alibaba Cloud and use the behavioral event message reporting API and the user identity reporting API. The details are as follows:
Prerequisites
Install the Java SDK
Install the Alibaba Cloud SDK for Java core library. For more information, see Install Alibaba Cloud SDK for Java.
NoteFor instructions on how to use the SDK, see Java examples.
Install the Quick Audience Java SDK. Open Aliyun Java SDK QuickAudience Public to download and install the Quick Audience Java SDK.
In the pom.xml file in your project directory, add the Maven dependency. After you add the dependency, the Maven project management tool automatically downloads the relevant JAR packages.
<!--Import the Alibaba Cloud Core package--> <dependency> <groupId>com.aliyun</groupId> <artifactId>aliyun-java-sdk-core</artifactId> <version>4.5.2</version> </dependency> <!--Import the Quick Audience Alibaba Cloud SDK--> <!-- https://mvnrepository.com/artifact/com.aliyun/aliyun-java-sdk-retailadvqa-public --> <dependency> <groupId>com.aliyun</groupId> <artifactId>aliyun-java-sdk-retailadvqa-public</artifactId> <version>3.3.16</version> </dependency>
Common request parameters
Parameter
Description
Required
Example
accessId
The Quick Audience instance ID. This is the access token for the caller.
Yes
retailadvqa-cn-xxxxxxxxx
organizationId
QA Organization ID
Yes
56621289-820e-433a-9947-xxxxxxxxx
accessId: Use the Alibaba Cloud account that you used to purchase Quick Audience to go to the Orders page. Click Details for the Quick Audience order to go to the order details page and obtain the instance name.

organizationId: Use your browser's developer tools to obtain the organization ID when you log on to Quick Audience, as shown in the following figure.
OpenAPI Endpoint list
Region
Region
Endpoint
cn-shanghai
Shanghai
quicka-public.cn-shanghai.aliyuncs.com
cn-shenzhen
Shenzhen
quicka-public.cn-shenzhen.aliyuncs.com
cn-zhangjiakou
Zhangjiakou
quicka-public.cn-zhangjiakou.aliyuncs.com
Behavioral event message reporting API
Request parameters
Parameter
Description
Parameter Type
Required
Example
eventMessageModelListStr
A list of behavioral event message bodies.
String
Yes
[ { "organizationId": "The organization ID. For information about how to obtain it, see Common request parameters.", "workspaceId": "The workspace ID. You can obtain it from Workspace Management.", "customerId": "The customer ID.", "eventSourceCode": "The event channel code.", "eventCode": "The event code.", "eventTime": 1651114368518, "extendAttributes": { "Event property": "Event property value", "outBizId": "A unique business ID. This is required." }, "customerIdList": [ { "customerId": "xxxxxxxxx", "idMapping": "mobile" }, { "customerId": "xxxxx@alibaba.com", "idMapping": "email" } ], "v": 1 } ]
Response parameters
Parameter
Description
Parameter Type
Example
success
Indicates whether the API call was successful.
Boolean
true
errorCode
The error code returned if the API call failed.
String
ES0110000002
errorDesc
The error message returned if the API call failed.
String
Authentication failed!
traceId
The request ID, which helps with troubleshooting.
String
None
Integrating the Demo
import com.alibaba.fastjson.JSONObject; import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.IAcsClient; import com.aliyuncs.exceptions.ClientException; import com.aliyuncs.profile.DefaultProfile; import com.aliyuncs.retailadvqa_public.model.v20200515.RecieveEventMessageRequest; import com.aliyuncs.retailadvqa_public.model.v20200515.RecieveEventMessageResponse; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Arrays; import java.util.HashMap; import java.util.Map; /** * Report event messages */ public class RecieveEventMessage { // An AccessKey of an Alibaba Cloud account has full permissions on all APIs. We recommend that you use a RAM user to make API calls or perform O&M. // We strongly recommend that you do not save your AccessKey ID and AccessKey secret in your project code. This can lead to an AccessKey leak and threaten the security of all resources in your account. // This example shows how to save the AccessKey ID and AccessKey secret in environment variables. // To save the environment variables, follow these steps: // For Linux and macOS systems // Run the following commands: // export SCA_AK_ENV=<access_key_id> // export SCA_SK_ENV=<access_key_secret> // Replace <access_key_id> with your AccessKey ID and <access_key_secret> with your AccessKey secret. static String accessKey = System.getenv("SCA_AK_ENV"); static String accessSecret = System.getenv("SCA_SK_ENV"); static String regionId = "cn-shanghai"; static String product = "retailadvqa-public"; static String endpointUrl = "quicka-public.cn-shanghai.aliyuncs.com"; static IAcsClient client = null; static { DefaultProfile profile = DefaultProfile.getProfile( regionId, // Region ID accessKey, // AccessKey ID of the RAM user accessSecret // AccessKey secret of the RAM user ); try { DefaultProfile.addEndpoint( regionId, product, endpointUrl ); } catch (Exception e) { } client= new DefaultAcsClient(profile); } public static void recieveEventMessage() throws ClientException { RecieveEventMessageRequest eventMessageRequest = new RecieveEventMessageRequest(); eventMessageRequest.setAccessId("retailadvqa-xx-xxxxxxxxx"); eventMessageRequest.setOrganizationId("56621289-820e-433a-9947-xxxxxxxxx"); EventMessageModel messageModel = new EventMessageModel(); messageModel.setOrganizationId(eventMessageRequest.getOrganizationId()); messageModel.setCustomerId("customer001"); messageModel.setEventSourceCode("eventsource001"); messageModel.setEventCode("event001"); messageModel.setEventTime(System.currentTimeMillis()); Map<String, String> extendAttributes = new HashMap<>(); extendAttributes.put("key1", "value1"); extendAttributes.put("key2", "123456"); messageModel.setExtendAttributes(extendAttributes); // This is a batch reporting API. The batch size limit is 100. eventMessageRequest.setEventMessageModelListStr(JSONObject.toJSONString(Arrays.asList(messageModel))); System.out.println(JSONObject.toJSONString(Arrays.asList(messageModel))); RecieveEventMessageResponse recieveEventMessageResponse = client.getAcsResponse(eventMessageRequest); System.out.println("result = " + JSONObject.toJSONString(recieveEventMessageResponse)); } public static void main(String... args) throws ClientException { recieveEventMessage(); } @Data public static class EventMessageModel { @ApiModelProperty("Organization ID") String organizationId; @ApiModelProperty(required = true, value = "User/Fan ID") String customerId; @ApiModelProperty("The app_key. If the event message does not contain an app_key, the automated marketing task calculation is not restricted by the channel.") String eventSourceCode; @ApiModelProperty(required = true, value = "Event code") String eventCode; @ApiModelProperty(required = true, value = "The actual time the event occurred") Long eventTime; @ApiModelProperty("The event extension property ID and its value") Map<String, String> extendAttributes = new HashMap<>(); @ApiModelProperty("The version number of the event message model") Integer v = 1; } }
User identity reporting API
Request parameters
Parameter
Description
Parameter Type
Required
Example
customerMessageModelListStr
A list of user identity message bodies.
String
Yes
[{"customerId":"customer001","customerIdList":[{"customerId":"13888888888","idMapping":"mobile"}],"organizationId":"56621289-820e-433a-9947-xxxxxxxxx","v":1}]
Response parameters
Parameter
Description
Parameter Type
Example
success
Indicates whether the API call was successful.
Boolean
true
errorCode
The error code returned if the API call failed.
String
ES0110000002
errorDesc
The error message returned if the API call failed.
String
Authentication failed!
traceId
The request ID, which helps with troubleshooting.
String
None
Integration demo
import com.alibaba.fastjson.JSONObject; import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.IAcsClient; import com.aliyuncs.exceptions.ClientException; import com.aliyuncs.profile.DefaultProfile; import com.aliyuncs.retailadvqa_public.model.v20200515.RecieveUserMessageRequest; import com.aliyuncs.retailadvqa_public.model.v20200515.RecieveUserMessageResponse; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Arrays; import java.util.List; /** * Report user identities */ public class RecieveCustomerMessage { // An AccessKey of an Alibaba Cloud account has full permissions on all APIs. We recommend that you use a RAM user to make API calls or perform O&M. // We strongly recommend that you do not save your AccessKey ID and AccessKey secret in your project code. This can lead to an AccessKey leak and threaten the security of all resources in your account. // This example shows how to save the AccessKey ID and AccessKey secret in environment variables. // To save the environment variables, follow these steps: // For Linux and macOS systems // Run the following commands: // export SCA_AK_ENV=<access_key_id> // export SCA_SK_ENV=<access_key_secret> // Replace <access_key_id> with your AccessKey ID and <access_key_secret> with your AccessKey secret. static String accessKey = System.getenv("SCA_AK_ENV"); static String accessSecret = System.getenv("SCA_SK_ENV"); static String regionId = "cn-shanghai"; static String product = "retailadvqa-public"; static String endpointUrl = "quicka-public.cn-shanghai.aliyuncs.com"; static IAcsClient client = null; static { DefaultProfile profile = DefaultProfile.getProfile( regionId, // Region ID accessKey, // AccessKey ID of the RAM user accessSecret // AccessKey secret of the RAM user ); try { DefaultProfile.addEndpoint( regionId, product, endpointUrl ); } catch (Exception e) { } client= new DefaultAcsClient(profile); } public static void recieveCustomerMessage() throws ClientException { RecieveUserMessageRequest recieveUserMessageRequest = new RecieveUserMessageRequest(); recieveUserMessageRequest.setAccessId("retailadvqa-xx-xxxxxxxxx"); recieveUserMessageRequest.setOrganizationId("56621289-820e-433a-9947-xxxxxxxxx"); CustomerMessageModel customerMessageModel = new CustomerMessageModel(); customerMessageModel.setOrganizationId(recieveUserMessageRequest.getOrganizationId()); customerMessageModel.setCustomerId("customer001"); CustomerIdModel idModel = new CustomerIdModel(); idModel.setCustomerId("13888888888"); idModel.setIdMapping("mobile"); customerMessageModel.setCustomerIdList(Arrays.asList(idModel)); // This is a message reporting API. The batch size limit is 100. recieveUserMessageRequest.setCustomerMessageModelListStr(JSONObject.toJSONString(Arrays.asList(customerMessageModel))); System.out.println(JSONObject.toJSONString(Arrays.asList(customerMessageModel))); RecieveUserMessageResponse recieveUserMessageResponse = client.getAcsResponse(recieveUserMessageRequest); System.out.println("result = " + JSONObject.toJSONString(recieveUserMessageResponse)); } public static void main(String... args) throws ClientException { recieveCustomerMessage(); } @Data public static class CustomerMessageModel { @ApiModelProperty("Organization ID") String organizationId; @ApiModelProperty(required = true, value = "User/Fan ID") String customerId; @ApiModelProperty(required = true, value = "User identity ID information, such as IDFA, IMEI, or mobile") List<CustomerIdModel> customerIdList; @ApiModelProperty("The version number of the user identity message model") Integer v = 1; } @Data public static class CustomerIdModel { @ApiModelProperty(required = true, value = "User/Fan ID") String customerId; /** The following user ID types are currently supported: 1) oneid: A custom ID type that does not map to Data Bank types. 2) email: Email address 3) mobile: Mobile phone number 4) taobao_id: Taobao ID 5) taobao_nick: Taobao nickname 6) imei: Mobile phone IMEI 7) idfa: Mobile phone IDFA 8) mac_org: Device MAC address 9) weibo_id_org: Weibo ID 10) alipay_id: Alipay ID 11) open_id: WeChat OpenID 12) union_id: WeChat UnionID */ @ApiModelProperty(required = true, value = "User ID type") String idMapping; } }
