The heat engine SDK supports automatic collection of click and page browsing events.
How to enable automatic collection:
List<AutoTrackEventType> autoTrackEventTypeList = new ArrayList<>();
autoTrackEventTypeList.add(AutoTrackEventType.AutoTrackAppViewScreen);
autoTrackEventTypeList.add(AutoTrackEventType.AutotrackAppClick);
SolarEngineConfig config = new SolarEngineConfig.Builder()
.enableAutoTrackEvent(autoTrackEventTypeList) //自动采集方法入口
.build();| parameter name | Parameter meaning |
| AutoTrackEventType.AutoTrackAppViewScreen | Automatically collect page browsing events |
| AutoTrackEventType.AutotrackAppClick | Automatically collect click events |
Method example
public void enableAutoTrack();Call example
import com.reyun.solar.engine.SolarEngineManager;
SolarEngineManager.getInstance().enableAutoTrack();Method example
public void disableAutoTrack();Call example
import com.reyun.solar.engine.SolarEngineManager;
SolarEngineManager.getInstance().disableAutoTrack();Method example
public void enableAutoTrackAppClick();Call example
import com.reyun.solar.engine.SolarEngineManager;
SolarEngineManager.getInstance().enableAutoTrackAppClick();Method example
public void disableAutoTrackAppClick();Call example
import com.reyun.solar.engine.SolarEngineManager;
SolarEngineManager.getInstance().disableAutoTrackAppClick();Method example
public void enableAutoTrackApViewScreen();Call the sample code:
import com.reyun.solar.engine.SolarEngineManager;
SolarEngineManager.getInstance().enableAutoTrackApViewScreen();Method example
public void disableAutoTrackApViewScreen();Call example
import com.reyun.solar.engine.SolarEngineManager;
SolarEngineManager.getInstance().disableAutoTrackApViewScreen();Method example
public void ignoreAutoTrackActivity(Class<?> ignoredActivity);Parameter related
| parameter name | Parameter meaning | Parameter Type | Is it mandatory? |
| ignoredActivity | Specify activities to ignore | Class<?> | yes |
Call example
import com.reyun.solar.engine.SolarEngineManager;
SolarEngineManager.getInstance().ignoreAutoTrackActivity(MainActivity.class);In addition to the above api, developers can also ignore automatic collection under a single Activity by adding the annotation @SolarEngineIgnoreTrackAppViewScreenAndAppClick to the Activity
Call the sample code:
import com.reyun.solar.engine.autotrack.SolarEngineIgnoreTrackAppViewScreenAndAppClick;
@SolarEngineIgnoreTrackAppViewScreenAndAppClick
public class MainActivity extends Activity {
}Method example
public void restoreAutoTrackActivity(Class<?> restoredActivity);Parameter related
| parameter name | Parameter meaning | Parameter Type | Is it mandatory? |
| restoredActivity | Specify the activity to be restored | Class<?> | yes |
Call example
import com.reyun.solar.engine.SolarEngineManager;
SolarEngineManager.getInstance().restoreAutoTrackActivity(MainActivity.class);Method example
public void ignoreAutoTrackActivities(List<Class<?>> ignoredActivities);Parameter related
| parameter name | Parameter meaning | Parameter Type | Is it mandatory? |
| ignoredActivities | Specify the collection of activities to ignore | List> | yes |
Call example
import com.reyun.solar.engine.SolarEngineManager;
List<Class<?>> classList = new ArrayList<>();
classList.add(MainActivity.class);
classList.add(LoginActivity.class);
SolarEngineManager.getInstance().ignoreAutoTrackActivities(classList);Method example
!#twenty one@!Parameter related
| parameter name | Parameter meaning | Parameter Type | Is it mandatory? |
| restoredActivities | Specify the restored Activity collection | Class<?> | yes |
Call example
!#twenty two@!Method example
!#twenty three@!Parameter related
| parameter name | Parameter meaning | Parameter Type | Is it mandatory? |
| ignoredViewType | Specify control types to ignore | Class | yes |
Call example
!#twenty four@!Method example
public void restoreViewType(Class restoredViewType);Parameter related
| parameter name | Parameter meaning | Parameter Type | Is it mandatory? |
| restoredViewType | Specify the type of control to restore | Class | yes |
Call example
import com.reyun.solar.engine.SolarEngineManager;
SolarEngineManager.getInstance().restoreViewType(Button.class);Method example
public void setViewId(View view, String viewId);Parameter related:
| parameter name | Parameter meaning | Parameter Type | Is it mandatory? |
| view | View that needs to set id attribute | View | yes |
| viewId | Set control ID | String | yes |
Call example
import com.reyun.solar.engine.SolarEngineManager;
SolarEngineManager.getInstance().setViewId(customBtn, viewId);Method example
public void setViewProperties(View view, JSONObject customProperties);Parameter related
| parameter name | Parameter meaning | Parameter Type | Is it mandatory? |
| view | View that needs to set id attribute | View | yes |
| customProperties | View custom attributes | JSONObject | yes |
Call example
import com.reyun.solar.engine.SolarEngineManager;
import org.json.JSONObject;
JSONObject customProperties = new JSONObject();
try {
//开发者自定义Json格式事件属性
customProperties.put("view_key1","view_value1");
customProperties.put("view_key2","view_value2");
} catch (JSONException e) {
///
}
SolarEngineManager.getInstance().setViewProperties(customBtn, customProperties);Call example
import com.reyun.solar.engine.autotrack.SolarEngineScreenAutoTrack;
public class MainActivity extends Activity implements SolarEngineScreenAutoTrack {
@Override
public String getScreenUrl() {
return "solarengine://page/inappevent";
}
@Override
public JSONObject getScreenAutoTrackProperties() throws JSONException {
JSONObject customProperties = new JSONObject();
customProperties.put("key1", "value1");
customProperties.put("key2", "value2");
return customProperties;
}
}If the auto-collection feature is used and obfuscation configuration is required during packaging, please add the following code to the obfuscation configuration file.
# TabLayout
-keep class android.support.design.widget.TabLayout$Tab {*;}
-keep class com.google.android.material.tabs.TabLayout$Tab {*;}
-keep class * extends android.support.design.widget.TabLayout$Tab {*;}
-keep class * extends com.google.android.material.tabs.TabLayout$Tab {*;}
# SwitchCompat
-keep class android.support.v7.widget.SwitchCompat {*;}
-keep class androidx.appcompat.widget.SwitchCompat {*;}
-keep class * extends android.support.v7.widget.SwitchCompat {*;}
-keep class * extends androidx.appcompat.widget.SwitchCompat {*;}
# ContextCompat
-keep class android.support.v4.content.ContextCompat {*;}
-keep class androidx.core.content.ContextCompat {*;}
-keep class * extends android.support.v4.content.ContextCompat {*;}
-keep class * extends androidx.core.content.ContextCompat {*;}
#ActionBar
-keep class android.support.v7.app.ActionBar {*;}
-keep class androidx.appcompat.app.ActionBar {*;}
-keep class * extends android.support.v7.app.ActionBar {*;}
-keep class * extends androidx.appcompat.app.ActionBar {*;}
# AppCompatActivity
-keep class android.support.v7.app.AppCompatActivity {
public android.support.v7.app.ActionBar getSupportActionBar();
}
-keep class androidx.appcompat.app.AppCompatActivity {
public androidx.appcompat.app.ActionBar getSupportActionBar();
}
-keep class * extends android.support.v7.app.AppCompatActivity {
public android.support.v7.app.ActionBar getSupportActionBar();
}
-keep class * extends androidx.appcompat.app.AppCompatActivity {
public androidx.appcompat.app.ActionBar getSupportActionBar();
}
# Annotation
-keepattributes *Annotation*
-keepattributes *JavascriptInterface*The _event_name of the page view event is _appViewScreen
Method example:
- (void)trackAppViewScreen:(UIViewController *)viewController withProperties:(NSDictionary *)properties;Parameter related:
| parameter name | Parameter meaning | Parameter Type | Is it mandatory? |
| viewController | The viewController to which the current page belongs | UIViewController | yes |
| properties | For descriptions of custom attributes passed in by developers, see the directory: 4. Custom Attributes | NSDictionary | no |
Call the sample code:
#import <SolarEngineSDK/SolarEngineSDK.h>
UIViewController *vc = self;
[[SolarEngineSDK sharedInstance] trackAppViewScreen:vc withProperties:@{@"custom_name":@"ActionViewController"}];The _event_name of the control click event is _applicationClick
The type of control click supports the following common control views or custom type views, such as: UIView, UIButton, UITextView, UIPickerView, UIDatePicker, UISegmentedControl, UISwitch, UISlider, UIStepper, etc.
Method example:
- (void)trackAppClick:(UIView *)view withProperties:(NSDictionary *)properties;Parameter related:
| parameter name | Parameter meaning | Parameter Type | Is it mandatory? |
| view | Clicked view element | UIView | yes |
| properties | For descriptions of custom attributes passed in by developers, see the directory: 4. Custom Attributes | NSDictionary | no |
Call the sample code:
#import <SolarEngineSDK/SolarEngineSDK.h>
UIButton *button = self.button;
[[SolarEngineSDK sharedInstance] trackAppClick: button withProperties:@{@"custom_name":@"UIButton"}];The SDK has its own automatic point collection function. The automatic point collection function is turned off by default. After it is turned on, the SDK will automatically collect "page browsing" and "control clicks" in the App.
The _event_name of the page view event is _appViewScreen
The _event_name of the control click event is _applicationClick
Note: After the automatic point collection of a page or control is turned on, the manual point collection API call of the corresponding page or control will be invalid.
The SDK provides two ways to enable automatic collection
1. Turn on automatic tracking when initializing the SDK
2. Call automatic tracking API
After the automatic tracking function is turned on, you can turn it off at any time. After turning it off, the SDK will no longer generate automatically collected tracking events.
Enable automatic tracking when initializing the SDK, sample code
SEConfig *config = [[SEConfig alloc] init];
config.autoTrackEventType = SEAutoTrackEventTypeAppClick | SEAutoTrackEventTypeAppViewScreen;
[[SolarEngineSDK sharedInstance] startWithAppKey:your_appKey userId:your_userId_SolarEngine config:config];Call automatic tracking API, sample code
// 开启自动追踪控件点击 和 页面浏览
[[SolarEngineSDK sharedInstance] setAutoTrackEventType:SEAutoTrackEventTypeAppClick | SEAutoTrackEventTypeAppViewScreen];
// 只开启自动追踪控件点击
[[SolarEngineSDK sharedInstance] setAutoTrackEventType:SEAutoTrackEventTypeAppClick];Turn off automatic tracking, sample code
// 关闭自动追踪
[[SolarEngineSDK sharedInstance] setAutoTrackEventType:SEAutoTrackEventTypeNone];The SDK adds an attribute se_ignoreAutoTrack to the Category of UIViewController to set whether to ignore the current page and whether to ignore automatic collection.
After ignoring it, the page will no longer generate the automatic buried event "appViewScreen"
After the page ignores automatic buried point collection, the automatic buried point collection of all controls in the page will also be ignored.
Note: Ignored pages or controls can support manual call for buried point collection.
Sample code
- (void)viewDidLoad {
[super viewDidLoad];
// 忽略当前 ViewController 自动追踪
self.se_ignoreAutoTrack = YES;
}The SDK supports ignoring the automatic point collection of certain types of controls. After ignoring it, this type of control will no longer generate the automatic point collection event "_applicationClick".
Note: Ignored pages or controls can support manual call for buried point collection.
Ignore certain types of control APIs
/// 忽略某类控件自送追踪
/// @param classList 需要忽略控件的类名,例如: @[[UIButton class]]
- (void)ignoreAutoTrackAppClickClassList:(NSArray<Class> *)classList;Sample code
// 忽略UIButton类型的自动埋点采集
[[SolarEngineSDK sharedInstance] ignoreAutoTrackAppClickClassList:@[[UIButton class]];The SDK supports adding custom attributes to pages or controls. When an automatic collection and buried event of the corresponding page or control is generated, the custom attributes will be brought along.
The SDK adds se_customProperties custom properties to UIViewController and UIView through Category.
Add custom attribute API
@interface UIView (SolarEngine)
/// 自定义属性,设置自定义属性后会跟随控件点击自动追踪事件一起上报
@property (nonatomic, copy) NSDictionary *se_customProperties;
@end
@interface UIViewController (SolarEngine)
/// 自定义属性,设置自定义属性后会跟随页面浏览自动追踪事件一起上报
@property (nonatomic, copy) NSDictionary *se_customProperties;
@endSample code
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"CellID"];
// 给Cell设置自定义属性,cell点击时产生的自动埋点采集将带着该自定义属性
cell.se_customProperties = @{@"key1":@"value1"};
return cell;
}The SDK can set the ScreenUrl for the current page. When the next page is automatically collected, the _referrer_name field will be the custom ScreenUrl just set.
Sample code
#import <SolarEngineSDK/SolarEngineSDK.h>
@interface ViewController ()<SEScreenAutoTracker>
- (NSString *)getScreenUrl {
return @"custom_screenUrl";
}SESDK.trackPageView();SESDK.trackPageClick(element);
// element 点击行为的元素对象
element对象上可绑定如下data属性
data-element-id 自定义id属性,如果没有配置时会自动抓取点击行为的元素对象元素的id属性。以_element_id进行上报。
data-element-target-url 当前点击行为发生跳转时的目标url, 如果没有配置时且当前点击行为的元素是a标签,那么会自动抓取a标签的href属性。以_element_target_url进行上报。
Note: The SDK will also automatically capture the following attributes of the element object of the click behavior:
1. The name attribute on the element is reported as _element_name
2. The class attribute on the element is reported as _element_class_name
3. Element text content is reported as _element_content
4. Element tag, reported with _element_type
The SDK supports the automatic point collection function. By default, the automatic point collection function is turned off. After it is turned on, the SDK will automatically collect "browse" and "click" in the web page, corresponding to the above 3.1 page browsing event and 3.2 page click event.
The _event_name of the page view event is _webViewScreen
The _event_name of the element click event is _webElementClick
Note: After the automatic point collection of a page or element is turned on, the manual point collection API call of the corresponding page or element will automatically complete the collection .
The SDK provides two ways to enable automatic collection
After the automatic tracking function is turned on, it can be turned off at any time. After turning it off, the SDK will no longer generate automatically collected tracking events.
Enable automatic tracking when initializing the SDK, sample code (see the SDK initialization section at the beginning of the document for parameter meanings)
SESDK.init({
config: {
autoTrackConfig: {
autoTrack: true,
autoTrackPageView: true,
autoTrackPageClick: true,
isTrackSinglePage: true,
}
}
})Automatic buried point acquisition configuration AutoTrackConfig parameter description:
| parameter | type | Is it required? | illustrate |
| autoTrack | boolean | no | Whether to enable automatic point collection for page browsing and clicks. The default is false and is not enabled. |
| autoTrackPageView | boolean | no | Whether to enable automatic point collection for page browsing. The default is false. If automatic point collection is enabled, manual calling of the page browsing API is prohibited. |
| autoTrackPageClick | boolean | no | Whether to enable automatic tracking collection of clicks on page elements. The default is false. If automatic collection is enabled, manual calling of the page element click API is prohibited. Note: If automatic tracking collection of clicks on page elements is enabled, the click event callback of the element cannot be set. Prevent the click event from bubbling up. |
| isTrackSinglePage | boolean | no | Whether to enable automatic point collection for page browsing in single-page applications. Default is true. |
Call automatic tracking API, sample code
// 开启自动追踪元素点击 和 页面浏览
// 方式一
SESDK.setAutoTrack({
autoTrack: true
});
// 方式二
SESDK.setAutoTrack({
autoTrackPageView: true,
autoTrackPageClick: true,
});
// 只开启自动追踪元素点击
SESDK.setAutoTrack({
autoTrackPageClick: true,
});Turn off automatic tracking, sample code
// 关闭自动追踪
// 方式一
SESDK.setAutoTrack({
autoTrack: false
});
// 方式二
SESDK.setAutoTrack({
autoTrackPageView: false,
autoTrackPageClick: false,
});The SDK provides setTrackPageView to set whether to ignore the automatic collection of the current page; and to add custom attributes to the page. When an automatic tracking event on the page occurs, the custom attributes will be brought along.
After ignoring it, the page will no longer generate the automatic burying event "_webViewScreen"
After the page ignores automatic click collection, the automatic click collection of all elements in the page will also be ignored.
Note: Ignored pages or elements can support manual call for buried point collection.
Sample code
SESDK.setTrackPageView(Array<{
path: trackConfig
}>)path: the path of the current page (the url of the page)
trackConfig parameter description:
| parameter name | Parameter meaning | Parameter Type | Is it mandatory? |
| ignoreTrack | Whether to ignore the automatic reporting of browsing behavior corresponding to the path, the default is false. If true, all click behaviors under the corresponding path will also be ignored and automatically reported. | boolean | no |
| customProperty | Custom attributes when the browsing behavior corresponding to the path is automatically reported | object (for specific requirements, see Event Reporting-Custom Attribute Requirements) | no |
Call example:
SESDK.setTrackPageView([
{
'https://portal.solar-engine.com/all/product/dashboard': {
ignoreTrack: false,
customProperty: {
a: 1,
b: 2
}
}
}
])The SDK supports ignoring the automatic tracking collection of a certain element. After ignoring it, the element will no longer generate the automatic tracking collection event "_webElementClick".
Note: Ignored elements can support manual call for buried point collection.
To ignore an element, bind the attribute data-ignore-track="true" to the element. After being ignored, the element can call the "element click event" method in 6.2
<div data-ignore-track="true">我是按钮</div>Note:
If event information is reported when the page is closed, the reporting request may fail. For example, when clicking a button triggers a page jump (not a single-page application jump), the information on the page before the jump may fail to be reported. At this time, when the automatic point collection of element clicks is turned on, it is recommended to ignore the automatic point collection of the current button and use manual calling to report the data.
// 元素点击事件的回调方法
function clickHandler() {
// 手动上报点击行为事件
SESDK.trackPageClick(element);
//延迟跳转页面,给 SDK 发送数据提供时间
setTimeout(function(){
window.location.href = url;
},500);
}The SDK supports adding custom attributes to elements. When an automatic collection and buried event of the corresponding element is generated, the custom attributes will be brought along.
The SDK adds custom attributes to the element by binding the attribute data-custom-property on the element. For specific requirements on the custom attribute format, see Event Reporting - Custom Attribute Requirements).
<div data-custom-property="{a: 1, b: 2}">我是按钮</div>SESDK.trackPageView();SESDK.trackPageClick(event);
// event 点击行为的event对象
点击的元素上可绑定如下data属性
data-element-id 自定义id属性,没有配置时会去元素的id。以_element_id进行上报。
data-content 元素自定义内容。以_element_content进行上报。
data-name 元素自定义name属性。以_element_name进行上报。
data-class-name 元素class属性。以_element_class_name进行上报。
data-type 元素类型-控件的类型,例如 Button。以_element_type进行上报。
data-element-target-url 当前点击行为发生跳转时的目标url。以_element_target_url进行上报。The SDK supports the automatic point collection function. The automatic point collection function is turned off by default. After it is turned on, the SDK will automatically collect the "browse" and "click" in the mini program page, corresponding to the above 4.1 page browsing event and 4.2 page click. event
The _event_name of the page view event is _mpViewScreen
The _event_name of the element click event is _mpElementClick
Note: After the automatic point collection of a page or element is turned on, the manual point collection API call of the corresponding page or element will be invalid.
The SDK provides two ways to enable automatic collection
1. Turn on automatic tracking when initializing the SDK
2. Call automatic tracking API
After the automatic tracking function is turned on, it can be turned off at any time. After turning it off, the SDK will no longer generate automatically collected tracking events.
Enable automatic tracking when initializing the SDK, sample code (see the SDK initialization section at the beginning of the document for parameter meanings)
SESDK.init({
config: {
autoTrackConfig: {
autoTrack: true,
autoTrackPageView: true,
autoTrackPageClick: true,
}
}
})Automatic buried point acquisition configuration AutoTrackConfig parameter description:
| parameter | type | Is it required? | illustrate |
| autoTrack | boolean | no | Whether to enable automatic point collection for page browsing and clicks. The default is false and is not enabled. |
| autoTrackPageView | boolean | no | Whether to enable automatic point collection for page browsing. The default is false. If automatic point collection is enabled, manual calls to the page browsing API are prohibited. |
| autoTrackPageClick | boolean | no | Whether to enable automatic click collection of page element clicks. The default is false. If automatic click collection is enabled, manual calling of the page element click API is prohibited. Only three click event types: tap, longpress, and longtap are supported. Note: If you enable automatic collection of clicks on page elements, then the element needs to be bound to an event to trigger a callback function, and the callback function must be registered in the Page or Component. |
Call automatic tracking API, sample code
// 开启自动追踪元素点击 和 页面浏览
// 方式一
SESDK.setAutoTrack({
autoTrack: true
});
// 方式二
SESDK.setAutoTrack({
autoTrackPageView: true,
autoTrackPageClick: true,
});
// 只开启自动追踪元素点击
SESDK.setAutoTrack({
autoTrackPageClick: true,
});
Turn off automatic tracking, sample code
// 关闭自动追踪
// 方式一
SESDK.setAutoTrack({
autoTrack: false
});
// 方式二
SESDK.setAutoTrack({
autoTrackPageView: false,
autoTrackPageClick: false,
});The SDK provides setTrackPageView to set whether to ignore the automatic collection of the current page; and to add custom attributes to the page. When an automatic tracking event on the page occurs, the custom attributes will be brought along.
After ignoring it, the page will no longer generate the automatic burying event "_mpViewScreen"
After the page ignores automatic click collection, the automatic click collection of all elements in the page will also be ignored.
Note: Ignored pages or elements can support manual call for buried point collection.
Sample code
SESDK.setTrackPageView(Array<{
path: trackConfig
}>)path: the path of the current page (the url of the page)
trackConfig parameter description:
| parameter name | Parameter meaning | Parameter Type | Is it mandatory? |
| ignoreTrack | Whether to ignore the automatic reporting of browsing behavior corresponding to the path, the default is false. If true, all click behaviors under the corresponding path will also be ignored and automatically reported. | boolean | no |
| customProperty | Custom attributes when the browsing behavior corresponding to the path is automatically reported | object (for specific requirements, see Event Reporting-Custom Attribute Requirements) | no |
Call example:
SESDK.setTrackPageView([
{
'pages/test/test': {
ignoreTrack: false,
customProperty: {
a: 1,
b: 2
}
}
}
])The SDK supports ignoring the automatic tracking collection of a certain element. After ignoring it, the element will no longer generate the automatic tracking collection event "_mpElementClick".
Note: Ignored elements can support manual call for buried point collection.
To ignore an element, bind the attribute data-ignore-track="true" to the element. After being ignored, the element can call the "element click event" method in 6.2
<view data-ignore-track="true" bindtap="clickHandle">我是按钮</view>
注:在页面page或component下需要注册clickHandle回调方法The SDK supports adding custom attributes to elements. When an automatic collection and buried event of the corresponding element is generated, the custom attributes will be brought along.
The SDK adds element custom properties by binding the attribute data-custom-property on the element. For specific requirements on the custom attribute format, see Event Reporting - Custom Attribute Requirements.
<view data-custom-property="{a: 1, b: 2}" bindtap="clickHandle">我是按钮</view>
注:在页面page或component下需要注册clickHandle回调方法