Retargetly is a tracking library for Android.
Android Studio
JDK
If your application uses fragments for full compatibility with the library, we recommend creating fragments with
getFragmentManager()
getSupportFragmentManager()
15 (Android 4.0.3–4.0.4 Ice Cream Sandwich)
To get a Git project into your build:
Add following lines in the Manifest:
<manifest ... >
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
...
</manifest>
Add it in the root build.gradle at the end of repositories:
allprojects {
repositories {
...
jcenter { url "http://jcenter.bintray.com/" }
maven { url 'https://jitpack.io' }
}
}
Add the dependency
dependencies {
implementation 'com.github.retargetly:sdk-android:2.1.0'
}
You must create a class that extends of application and in the oncreate add the following two methods:
RetargetlyParams.Builder(source_hash)
[.changeSomeConfig(false)]
[.changeSomeOtherConfig(true)]
.build();
Which is used to change some default configurations of the behavior of the library (configurations can be concatenated one after another), and:
Retargetly.init(this,params);
Which is used to initialize the library.
public class App extends Application {
String source_hash = "iSkGs8ZOEqgM3hKHE4AHttSutHjEaLMK";
@Override
public void onCreate() {
super.onCreate();
RetargetlyParams params = new RetargetlyParams.Builder(source_hash)
.isSendDeviceNameEnabled(false)
.build();
Retargetly.init(this,params);
}
}
In this case, we built the parameters with "isSendDeviceNameEnabled(false)", and it will prevent device model name to be sent to the DMP. You can add as many individual configurations as available, and also there is an additional method "sendOptionalParams(false)" which will set all possible configurations in false, thus not sending any of those optional parameters.
RetargetlyUtils.callEventDeeplink(Map<String,String> value);
RetargetlyUtils.callEventDeeplink(Map<String,String> value, CustomEventListener customEventListener);
If you want the SDK to detect when a deeplink is opened, you must set in the init the class received deeplinks, for example:
RetargetlyParams params = new RetargetlyParams.Builder(source_hash)
.classDeeplink(myclassdeeplinks.class)
.build();
Retargetly.init(this,params);
If you not set your class Deeplink in the init, the SDK detect automatically in your first opened activity.
RetargetlyUtils.callCustomEvent(Map<String,String> value);
RetargetlyUtils.callCustomEvent(Map<String,String> value, CustomEventListener customEventListener);
public interface CustomEventListener {
void customEventSuccess();
void customEventFailure(String msg);
}
Map obj = new HashMap();
obj.put("Event","Test Event");
RetargetlyUtils.callCustomEvent(obj);
public class MainActivity extends AppCompatActivity implements CustomEventListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Map obj = new HashMap();
obj.put("Event","Test Event");
RetargetlyUtils.callCustomEvent(obj, this);
}
@Override
public void customEventSuccess() {
Toast.makeText(getApplication(),"Custom event send",Toast.LENGTH_SHORT).show();
}
@Override
public void customEventFailure(String msg) {
Toast.makeText(getApplication(),msg,Toast.LENGTH_SHORT).show();
}
}
D/Retargetly -: First Activity MainActivity
//Success
D/Retargetly -: Event : open, status: 200
//Failure
D/Retargetly -: Event : open, 500
D/Retargetly -: Activity MainActivity
D/Retargetly -: Fragment MainFragment
//Success
D/Retargetly -: Event : change, value:MainActivity, status: 200
//Failure
D/Retargetly -: Event : change, 500
//Success
D/Retargetly -: Event : Custom , value:{Event=Test event}, status: 200
//Failure
D/Retargetly -: Event : custom, 500
- Android Studio - Ide development
For the versions available, see the tags on this repository.
- Device ID: anonymous advertising identificator, the ones provided by Google and Apple.
- Type of event: which is the event that triggered the data reception, it may be application open, custom event (if configured), geo event (if activated), or deeplink (if configured).
- Custom Data: this is only for custom events. Custom events send custom data in key/value format.
- Lat/Long/Accuracy (if geo is active): when gps data is being tracked on the SDK, geo events are being sent to the DMP.
- Installed apps: only on open events. It sends a list of installed apps on the device (only works for android).
- Manufacturer: device manufacturer name.
- Device: celular model.
- Application: which is the current application that is sending the data.
- Language: which is the device configured language.
- Ip: which is the IP address of the device.
- Wifi Name: which is the name of the wifi that the user is connected to.