merchant
|
Tracking SDK
|
1.0
|
Android
|
TradeTracker SDK provides functionalities to track statistics of app install, usage, leads and sales generated from the app. The SDK is compatible with Android 4.0 (API version 14) and above. Android Studio is the recommended development environment.
Downloading the SDK Download the SDK from following link: TradeTracker Android SDK
Importing the SDK To import AAR file into your Android Studio project, go to File -> New -> Import module -> import JAR/.AAR package -> Select the path to AAR file -> select ‘Finish’.
To add a dependency to the SDK, go to Module Settings -> Select your app module -> Select dependencies tab -> Select ‘+’ option -> Module dependency -> Select the TradeTracker SDK -> select ‘OK’.
Using the SDK
Permissions Update your project's AndroidManifest.xml file to include the INTERNET and ACCESS_NETWORK_STATE permissions.
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="your.app.package"> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <application android:name="MyApplication"> ... </application> </manifest> INSTALL_REFERRER broadcast receiver In the AndroidManifest.xml, add the following receiver as the FIRST receiver for INSTALL_REFERRER.
<application [......] <receiver android:name="com.tradetracker.CampaignTrackingReceiver" android:exported="true"> <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER"/> </intent-filter> </receiver> </application> Note : If your app has multiple broadcast receivers for INSTALL_REFERRER action, then you can write a custom broadcast receiver which receives the INSTALL_REFERRER broadcast and passes the broadcast intent to all other receivers from different SDKs.
public class CustomBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { CampaignTrackingReceiver tradeTrackerReceiver = new CampaignTrackingReceiver(); tradeTrackerReceiver.onReceive(context, intent); } } Then in manifest file, you can add this as receiver for INSTALL_REFERRER action.
<application [......] <receiver android:name="com.your.package.CustomBroadcastReceiver" android:exported="true"> <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER"/> </intent-filter> </receiver> </application> SDK initialization Initialize the TradeTracker SDK in the Application class. This must be called before calling any other APIs on the shared singleton TradeTracker object.
public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); TradeTracker.getInstance().init(this, "your-app-id"); } } SDK Logging (Optional) You can enable the SDK logging to see the logs generated by the SDK during debugging. But remember to disable the logging before releasing the app.
TradeTracker.getInstance().enableLogging(LogLevel.DEBUG); Installed Application Deep linking has to be handled in your app to update the "referrer". In a case, if a user has already installed the app using an affiliate site and open the app using another affiliate site, the "referrer" has to be updated to get new MaterialID and AffiliateID. Following is an example;
import com.tradetracker.utility.Constants; import com.tradetracker.utility.ParameterNames; import com.tradetracker.utility.PreferenceUtility; ..... @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detailed_tracking); Intent intent = getIntent(); Uri data = intent.getData(); if(data != null && data.isHierarchical()){ String referrer = data.getQueryParameter(ParameterNames.REFERRER); Context context = getApplicationContext(); if (!TextUtils.isEmpty(referrer)) { PreferenceUtility.saveStoreReference(context, referrer); TradeTracker.getInstance().trackAppStart(); } } initViews(); }
Tracking of the app start event Track the app start in onCreate() function of the Launcher activity.
public class LauncherActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_launcher); TradeTracker.getInstance().trackAppStart();; }
Tracking of custom leads To manually trigger a lead you can use the following API.
TradeTracker.getInstance().trackCustomLead(descrMerchant, descrAffiliate, eml, pid, tid);
Tracking of custom sales (in-app purchases) To manually trigger a sale you can use the following API:
TradeTracker.getInstance().trackCustomSales(tam, descrMerchant, descrAffiliate, eml, pid, tid);
In addition to the parameters listed in the table above, you may pass on the order amount ("tam") as a Double, e.g. 123.45.
Testing After the integration of the TradeTracker SDK, make sure that SDK receives the install referrer properly.
Testing install referrer by uploading a beta app to play store You can upload a beta version of your app to google play store & use a sample advertising link to install the app. Ex : https://play.google.com/store/apps/details?id=your.package.name&referrer={{MaterialID}}::{{AffiliateID}} On the first launch of the app, SDK receives the install referrer info from play store & uses it as a param in subsequent events fired. Enable the SDK logging as described in section 2.4 to see the event logs generated by the SDK.
Testing install referrer with ADB To verify that SDK is receiving the install referrer info properly, install your app in the device & run the following command in the Terminal:
adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n com.your.package/com.tradetracker.CampaignTrackingReceiver --es "referrer" "test_referrer_key=test_referrer_value"
Enable the SDK logging as described above to see the event logs generated by the SDK.
Shortlink to this article: https://sc.tradetracker.net/implementation/overview?f[id]=45
|
23-Sep-2019 13:03:14 |