For Android Version 4.3.3
NOTE: The Android sample app was developed using Android Studio environment.
AppsFlyer’s Sample App enables you to see how our newest SDK is integrated into a working project.
You can use this project as a reference to your own project to verify and debug the integration process. In addition, you can use the sample app to run end-to-end test scenarios and review the results in your dashboard, such as reports and Push API.
For your convenience, the project contains instructions in the comments under the tag: AppsFlyer.
Using the Sample App for Testing
The following sections are covered in this guide:
- Using the Sample App
- Customizing your Sample App
You can use this project to test the functionality of the SDK and view changes made in your AppsFlyer dashboard.
Follow these instructions to link the project to your AppsFlyer account:
- Open the project using Android Studio
- Change the package name to match the name configured in your AppsFlyer dashboard (your new package name must be unique). Make sure your new package name appears in all references throughout the project (Make sure the same name appears in build.gradle).
- Under the Java directory, open the Java file MainActivity.java.
You can find the method located in onCreate
Replace your_dev_key with the one enlisted under the SDK Integration section of your AppsFlyer dashboard.
- (Optional) In the same file MainActivity.java, find the method in onCreate:
Change your_gcm_id to your GCM project’s ID located in your google developer console. Alternatively, you can comment out this method if you do not want to track uninstall data.
4. Build the App to your test device. Make sure your test device is whitelisted in your AppsFlyer dashboard - refer to this article for more information.
Now you can test the sample app on your device, and see the changes in your dashboard!
Make sure to use a custom generated AppsFlyer link before installing the app on your device, to receive a non-organic Install.
Using the Sample App
Once you have configured the project to be associated with your AppsFlyer account, you can open it and the following screen is displayed:
- Attribution Values: Shows the the core values of your installation - You can see if you received a non-organic install after clicking a custom link, as well as your media source, click time (on your link) and install time (on your device).
- Track Event: Click this button to launch an event tracking call which you can view in your dashboard (See Deeplinking below for details of customization of this button).
Customizing your Sample App
The sample app project contains a button to trigger a custom event tracking call.
By default, this button is set to track a purchase event which can then be viewed in your dashboard as a revenue increase of $200.
If you wish to test additional events, you can find the code for this tracking in the MainActivity.java file, under the buttonOnClick method.
To review all available event types which you can track with AppsFlyer’s SDK, refer to this article.
In addition, under the registerConversionListener method, you can find several attribution parameters which are shown in a TextView. To view all available parameters, refer to this article.
NOTE: For unpublished apps and parameters other than the ones which are printed in the default code of the sample app, are returned as Null.
To edit your deeplinking scheme:
1. Go to the AndroidManifest file.
2. Edit the <data> tags under <intent-filter>, inside Deeplink <activity>.
3. Generate a custom media source link using AppsFlyer’s dashboard. Refer to this article for guidance. Make sure to include "&advertising_id=YOUR_
4. Add the following tags to your link
- Using only a scheme
- Using a scheme and a host
In your AndroidManifest file you can view your custom deeplinks’ schemes and hosts and change them as required. They are located under the <intent-filter> tab inside the Deeplink <activity> tab.
By default, you can test the deeplinking in the sample app using the following links:
- For http://aftest.com
- For aftest://
Ensure the app is installed on your device before testing the deeplinks, as unpublished apps are not redirected to Google Play in case they are not pre-installed.
Click one of the deeplinks and you are redirected to the Deeplink Activity, which cannot be accessed in any other way -
You can also view the link you navigated from into the activity.
By using the sendDeepLinkData method in the Deeplink.java file (located in onCreate), you can attribute the deeplinking to the corresponding media source.