Skip to content

DanielWorld/UserTracker

Repository files navigation

UserTracker

UserTracking SDK : Tracks Users action

Development Environment

  • Apple OS X 10.10 & Windows 10
  • Android Studio 1.4.0
  • Java version 1.8.0_45
  • Android 6 (23)

Environment Settings

  • in app/build.gradle minSdkVersion should be 10 or higher level

AndroidManifest.xml Settings

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>

How to use UserTracker

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)

public final void sendFirstRun()

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();

public final void sendForeground(String tag)

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);

public final void sendBackground(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);

public final void sendAction(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);

How to test InstallReferrer in local

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"

Caution

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()

About

UserTracking SDK : Tracks Users action

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages