-
Notifications
You must be signed in to change notification settings - Fork 0
Sending background hits da2d4d
Identification enables you to distinguish hits sent following direct usage of your application from hits sent in the background, automatically and independently of the user, with the help of AsyncTask for example.
The tracker possesses a context object, which possesses a property, backgroundMode. This is BackgroundMode-type enumeration.
By default, this property is set to Normal. In all cases of tagging automatic behaviours independent of the user, it should be set to Task.
To tag these types of operations, you must initialise a new tracker within your class in the case of a Service.
In the case of an AsyncTask, it is recommended to use a dedicated instance of the tracker. Should you wish to use a single instance of the tracker, please remember to reset the property to Normal at the end of AsyncTask execution.
- Tagging a service
public class DemoService extends IntentService {
private Tracker tracker;
public DemoService(String name) {
super(name);
}
@Override
public void onCreate() {
super.onCreate();
tracker = ATInternet.getInstance().getTracker("serviceTracker");
tracker.Context().setBackgroundMode(Context.BackgroundMode.Task);
}
@Override
protected void onHandleIntent(Intent intent) {
// Do the work associated with the service
tracker.Gestures().add("intent received").sendDownload();
}
}- Tagging an AsyncTask with a dedicated tracker
new AsyncTask<String, String, String>() {
Tracker tracker = ATInternet.getInstance().getTracker("asyncTaskTracker");
@Override
protected void onPreExecute() {
super.onPreExecute();
tracker.Context().setBackgroundMode(Context.BackgroundMode.Task);
}
@Override
protected String doInBackground(String... params) {
tracker.Gestures().add("async task").sendDownload();
return null;
}
}.execute();- Tagging an AsyncTask with a global tracker
new AsyncTask<String, String, String>() {
Tracker tracker = ATInternet.getInstance().getDefaultTracker();
@Override
protected void onPreExecute() {
super.onPreExecute();
tracker.Context().setBackgroundMode(Context.BackgroundMode.Task);
}
@Override
protected String doInBackground(String... params) {
tracker.Gestures().add("async task").sendDownload();
return null;
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
tracker.Context().setBackgroundMode(Context.BackgroundMode.Normal);
}
}.execute();
}Last update: 05/04/2018
-
Data API
- Data flow
- Advice optimizations data flow
- Error codes data flow
- Faq data flow
- General information data flow
- Technical information data flow
- Reporting API v3
- Getting started
- Methods
- Parameters
- Technical information
- REST API
- Campaigns
- Custom variables
- Getting started rest
- Methods rest
- Response structure parameters rest
- Fixed periods
- Parameters compatibility
- Relative periods
- Structure of the response
- “code” parameter
- “columns” parameter
- “evo” parameter
- “filter” parameter
- “include” parameter
- “lng” parameter
- “max-results” parameter
- “page-num” parameter
- “period” parameter
- “period” parameter: “H” v. “He” & “MN” v. “MNe”
- “retention” parameter
- “segmentdesc” parameter
- “segment” parameter
- “sep” parameter
- “sort” parameter
- “space” parameter
- Technical specifications rest
- Data flow
-
Data collection
- Android
- Advanced features
- Campaigns
- Changelog
- Content
- Ecommerce
- Getting started
- Users
- Apple
- Advanced features
- Campaigns
- Changelog
- Content
- Ecommerce
- Getting started
- Users
- General
- Cddc renew staging process
- Changelog
- Craft your hit
- Encoded parameters
- Server side cookie management
- Supported taggings
- Tagging deletion
- Utilisation of dispatch sdks
- JavaScript
- Advanced features
- Campaigns
- Changelog
- Content
- Ecommerce
- Getting started
- Partners javascript
- Users
- Piano Analytics
- Event tagging piano analytics
- Getting started piano analytics
- Piano analytics tagging
- Feeding piano analytics with as2 tagging
- Tagging custom properties sdk
- Android