UserTracking SDK : Tracks Users action
- Apple OS X 10.10 & Windows 10
- Android Studio 1.4.0
- Java version 1.8.0_45
- Android 6 (23)
- in app/build.gradle minSdkVersion should be 10 or higher level
INTERNET, GET_ACCOUNTS, READ_PHONE_STATE are required
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
set app id in string.xml
<resources> ... <string name="app_id">0123456789</string> </resources>
To read app id, set meta-data in AndroidManifest.xml
<application ...> ... <meta-data android:name="com.danielworld.utility.appId" android:value="@string/app_id" />
Tracking data is transmitting through service
<service android:name="com.danielworld.usertracker.service.TrackingService" />
Set Receiver to get InstallReferrer
<receiver android:name="com.danielworld.usertracker.receiver.InstallReferrerReceiver" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER" /> </intent-filter> </receiver>
You can get UserTracker like this
synchronized public static final UserTracker getInstance(Context context)
UserTracker gives you 4 methods
- public final void sendFirstRun()
- public final void sendForeground(String tag)
- public final void sendBackground(String tag)
- public final void sendAction(String tag)
This is called when application execute for the first time
It won't be transmitted unless install referrer is arrived
If it is called in Activity
UserTracker.getInstance(getApplicationContext()).sendFirstRun();
If it is called in Fragment
UserTracker.getInstance(getActivity().getApplicationContext()).sendFirstRun();
This is called when application is on the foreground mode
If String tag is null then it will print null
If it is called in Activity
UserTracker.getInstance(getApplicationContext()).sendForeground(String tag);
If it is called in Fragment
UserTracker.getInstance(getActivity().getApplicationContext()).sendForeground(String tag);
This is called when application is in the background mode
If String tag is null then it will print null
If it is called in Activity
UserTracker.getInstance(getApplicationContext()).sendBackground(String tag);
If it is called in Fragment
UserTracker.getInstance(getActivity().getApplicationContext()).sendBackground(String tag);
This is called when application does certain action If String tag is null then it will print null
If it is called in Activity
UserTracker.getInstance(getApplicationContext()).sendAction(String tag);
If it is called in Fragment
UserTracker.getInstance(getActivity().getApplicationContext()).sendAction(String tag);
Using terminal, you can deliver install referrer to your device
Go to folder where adb is installed
$ adb shell $ am broadcast -a com.android.vending.INSTALL_REFERRER -n danielworld.usertracker/com.danielworld.usertracker.receiver.InstallReferrerReceiver --es "referrer" "com=userTracker&name=daniel&com=danielworld&id=234"
sendFirstRun() will invoke only one time when install referrer is arrived before calling it
If install referrer wasn't received when sendFirstRun() is invoked, sendFirstRun() will be called without install referrer and wait for install referrer to send sendFirstRun()