Skip to content

Ayaan1/android_viewtracker

 
 

Repository files navigation

ViewTracker-Android

Overview

ViewTracker is a data collection library for click and exposure event in user interaction, based on the view event delegate and filter, used to insert statistical code tracelessly and noninvasively.

Features

  • Two platforms support (iOS & Android).
  • Collect click and exposure event tracelessly, noninvasively.
  • Support multiple application scenarios(begin to scroll, end to scroll, auto scroll, window replace inside page, switch page in the TabActivity, enter into the next page, switch back and forth when press Home button).
  • Caller can set the custom data commit method.
  • Custom exposure event, including exposure time threshold and dimension threshold, support server configuration.
  • Little impact on the frame FPS(Frame Per Second) performance.

Get started

Import dependencies

use gradle:

compile('com.alibaba.android:viewtracker:1.0.0@aar')

Init configuration when app start

/**
 * init SDK
 *
 * @param mContext   global application
 * @param mTrackerOpen whether or not track click event
 * @param mTrackerExposureOpen whether or not track exposure event
 * @param printLog       whether or not print the log
 */
TrackerManager.getInstance().init(mContext, mTrackerOpen, mTrackerExposureOpen, printLog);

Dynamic configuration(optional)

JSON server configuration for click event:

{
    "masterSwitch": true, // whether or not track click event
    "sampling":100
}

JSON server configuration for exposure event:

{
    "masterSwitch": true, // whether or not track exposure event
    "timeThreshold": 100, // time threshold
    "dimThreshold": 0.8, // dimension threshold
    "exposureSampling": 100, // sampling frequency
    "batchOpen":false // whether or not commit the exposure event log in batch or one by one
}

The app send a broadcast after pull configuration, internal receiver get it to modify configuration.

JSONObject config = new JSONObject();
// get server configuration for click event
...
JSONObject exposureConfig = new JSONObject();
// get server configuration for exposure event
...
Intent intent = new Intent(ConfigReceiver.ACTION_CONFIG_CHANGED);
intent.putExtra(ConfigReceiver.VIEWTRACKER_CONFIG_KEY, config.toString());
intent.putExtra(ConfigReceiver.VIEWTRACKER_EXPOSURE_CONFIG_KEY, exposureConfig.toString());
context.sendBroadcast(intent);

Set common info inside page, including page name.(optional)

Generally call this in onReumse(),

HashMap<String, String> args = new HashMap<String, String>();
// set page name
args.put(TrackerConstants.PAGE_NAME, pageName);
// set attached common info
...
TrackerManager.getInstance().setCommonInfoMap(args);

Set commit method externally, implement IDataCommit interface.

Class DataCommit implments IDataCommit {}
TrackerManager.getInstance().setCommit(new DataCommit());

Caller set tag for view.

  • Only set view name for collected views.
String viewName = "Button-1";
view.setTag(TrackerConstants.VIEW_TAG_UNIQUE_NAME, viewName);
  • set attached info for collected views.
HashMap<String, String> args = new HashMap<String, String>();
args.put(key, value);
...
view.setTag(TrackerConstants.VIEW_TAG_PARAM, args);
  • Set like this if views inside page need to attach common info.
HashMap<String, String> args = new HashMap<String, String>();
args.put(key, value);
...
getWindow().getDecorView().setTag(TrackerConstants.DECOR_VIEW_TAG_COMMON_INFO, args);

Author

for Q&A

Because the QR code of WeChat Group is valid for a short period , you can join us by search Sunshine07de in WeChat.

for dingTalk

About

A data collection library for click and exposure event with the UI.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Java 100.0%