Auto-tracking
1. Enable auto-tracked events
You can call enableAutoTrack and pass in a TDAutoTrackEventType type to enable auto-tracking. Six types are currently supported:
ta_app_start: the app enters the foreground. The corresponding type isTDAutoTrackEventType.APP_STARTta_app_end: the app enters the background. The corresponding type isTDAutoTrackEventType.APP_ENDta_app_install: the app is opened for the first time after installation. The corresponding type isTDAutoTrackEventType.APP_INSTALLta_app_crash: the app crashes because of an uncaught exception. The corresponding type isTDAutoTrackEventType.APP_CRASHta_app_view: triggered when the app navigates between routes with React Navigation. The corresponding type isTDAutoTrackEventType.APP_VIEW_SCREEN(supported in v3.2.0 and later)ta_app_click: The app element click event is triggered when the user clicks an element. The corresponding type isTDAutoTrackEventType.APP_CLICK(supported in v3.2.0 and later)
Note the following about auto-tracked events:
- Auto-tracked events are implemented in the native SDK, so dynamic super properties currently can't be added to auto-tracked events.
- If you need to set the distinct ID or super properties, set them before you enable auto-tracked events.
Example of enabling auto-tracking:
TDAnalytics.enableAutoTrack(TDAutoTrackEventType.APP_START | TDAutoTrackEventType.APP_END | TDAutoTrackEventType.APP_INSTALL| TDAutoTrackEventType.APP_CRASH | TDAutoTrackEventType.APP_CLICK | TDAutoTrackEventType.APP_VIEW_SCREEN);
2. Details
2.1 Page view event
The app page view event supports React Navigation ^2.0 ~ ^6.0
Triggered when the app navigates between routes with React Navigation. Event details:
-
Event name: ta_app_view
-
Preset properties:
#screen_name: string, page name#title: string, page title#referrer: string, referrer address -
How to enable:
- Call
enableAutoTrackand pass inTDAutoTrackEventType.APP_VIEW_SCREEN
TDAnalytics.enableAutoTrack(TDAutoTrackEventType.APP_VIEW_SCREEN);- Run the script
node node_modules/react-native-thinking-data/ThinkingDataRNHook.js -run - Call
-
Set custom page properties: When navigating with Navigation, you can add custom properties to params. The SDK automatically uses the values in params to supplement or overwrite the properties of the app page view event.
navigation.navigate('PageB', {
thinkingdataparams: {
name: 'name_A',
'#title': 'Second page',
'#screen_name': "page_B"
}
});
To customize #title and #screen_name, pass them in the thinkingdataparams parameter.
- Ignore a single page view event: Add the TDIgnoreViewScreen property to thinkingdataparams and set it to true to ignore that page view event
navigation.navigate('PageB', {thinkingdataparams: {name: 'name_A','#title': 'Second page','#screen_name': "page_B",TDIgnoreViewScreen: true}});
2.2 Element click event
The app element click event supports React Native 0.23 ~ 0.70.0
The app control click event is triggered when the user clicks a control
-
Event name: ta_app_click
-
Preset properties:
#screen_name: string, page name#title: string, page title#element_content: string, element content -
How to enable:
- Call
enableAutoTrackand pass inTDAutoTrackEventType.APP_CLICK
TDAnalytics.enableAutoTrack(TDAutoTrackEventType.APP_CLICK);- Run the script:
node node_modules/react-native-thinking-data/ThinkingDataRNHook.js -run - Call
-
Set custom element properties: Add the custom property thinkingdataparams to the element
<CustomButton
title="Button"
thinkingdataparams={{
name: 'button',
pro_key:'pro_value'
}}
/>
- Ignore a single element click event: Add the TDIgnoreViewClick property to thinkingdataparams and set it to true to ignore that element's click event
<CustomButton
title="Button"
thinkingdataparams={{
name: 'button',
pro_key:'pro_value',
TDIgnoreViewClick: true
}}
/>
3. Set custom properties for auto-tracked events
You can call enableAutoTrack to set properties for auto-tracked events
TDAnalytics.enableAutoTrack(TDAutoTrackEventType.APP_START,{
auto_name: "xxx",
auto_age: "xxx"
})

