跳转到主要内容
PRODUCT DOCUMENTS

快速找到所需文档,高效完成接入与排障

浏览产品文档与友盟 Skill,展开目录并阅读正文。

自定义事件的集成方法

问题描述:

  • 事件统计参数使用

  • 怎么设置事件参数

  • 怎么设置自定义事件

  • 自定义事件集成方法

解决方案:

使用自定义事件功能请先登录U-App统计后台,在“统计分析->设置->事件”(子账户由于权限限制可能无法看到“设置”选项,请联系主账号开通权限。)页面中添加相应的事件id(event id请使用英文、数字、下划线、中划线、小数点及加号)进行定义,不可使用中文等其他字符进行定义),然后服务器才会对相应的事件请求进行处理。

事件统计对应的API如下:

  • (void)event:(NSString *)eventId;

  • (void)event:(NSString )eventId label:(NSString )label;

  • (void)event:(NSString )eventId attributes:(NSDictionary )attributes;

  • (void)event:(NSString )eventId attributes:(NSDictionary )attributes counter:(int)number;

  • (void)beginEvent:(NSString *)eventId;

  • (void)endEvent:(NSString *)eventId;

  • (void)beginEvent:(NSString )eventId label:(NSString )label;

  • (void)endEvent:(NSString )eventId label:(NSString )label;

  • (void)beginEvent:(NSString )eventId primarykey :(NSString )keyName attributes:(NSDictionary *)attributes;

  • (void)endEvent:(NSString )eventId primarykey:(NSString )keyName;

  • (void)event:(NSString *)eventId durations:(int)millisecond;

  • (void)event:(NSString )eventId label:(NSString )label durations:(int)millisecond;

  • (void)event:(NSString )eventId attributes:(NSDictionary )attributes durations:(int)millisecond;

eventId:网站上注册的事件Id NSString型,字符长度不能大于128字节,不能为空,关键词_$!deep_link是友盟SDK保留字段,不能作为eventId使用。

label:分类标签,不同的标签会分别进行统计,方便同一事件的不同标签的对比,为nil或空字符串时后台会生成和eventId同名的标签 NSString型。

attributes:自定义属性 NSDictionary型,attributes的key和value必须是string类型且不能使用空格和特殊字符,key不能大于128字节,value不能大于256字节,关键字id, ts, du, dplusst, $!link是友盟SDK保留字段,不能作为key使用,attributes不能超过100个。

counter:计数值 int型

millisecond:时长 int型,单位为毫秒,值需要大于0小于7200000。

primarykey:用于和event_id一起标示一个唯一事件,并不会被统计, NSString型不能为空。

如需要使用beginEvent和endEvent方法需要传递相同的eventId 和 primarykey。