Google Play Install Referrer is the API that is used in most of the applications but it is not been seen in the app. This functionality works under the hood and is used to check the sources from where the app is getting most of the downloads. Google Play Install Referrer API tells us that from where the app has to go installs and the sources. This will helps us to improve the presence of our apps on different platforms.
What is the use of Google Play Referrer API?
Google Play Referrer API provides us information from where our app has been installed whether it may be play store or any other platform. With the help of this API, we can track the actions which are taken by the user to download our App. Below are some of the important data which we can gather using this API.
- With the help of this API, we can track from where the user has installed our application. We can get the URL from which our app has been downloaded.
- We can get the timestamp when the user clicks on the referrer URL.
- We can get the timestamp of the user when the user downloads our app from a specific URL.
- We can get the app version when our app was first installed.
- We can track whether the user has used the app’s instant experience with the previous 7 days.
What we are going to build in this article?
We will be building a simple application in which we will be adding our Google Play Referrer API and we will be displaying the data which is tracked by this API in a simple text view. Note that as we have not published our App to Google Play. So we will only get the source from which our app installed as organic. Below is the screenshot in which we will get to see what we are going to build in this article. Note that we are going to implement this project using the Java language.
Step by Step Implementation
Step 1: Create a New Project
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Java as the programming language.
Step 2: Add the dependency for Google Play Referrer API in the build.gradle file
Navigate to Gradle scripts and then to build.gradle(Module) level. Add below line in build.gradle file in the dependencies section.
// below is the dependency for referer
Step 3: Working with the activity_main.xml file
Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Below is the code for the activity_main.xml file.
Step 4: Working with the MainActivity.java file
Go to the MainActivity.java file and refer to the following code. Below is the code for the MainActivity.java file. Comments are added inside the code to understand the code in more detail.
Now run your app and see the output of the app.
Note: As our app is not published on Google Play so we will only get the referrer details as organic and other details will get as zero.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.