I need to get data from the referral link

Hello!

I have a problem and I cannot solve it.
Help me please!
I am making a game for android and a referral system.
At the first start of the game, the user receives a link https://play.google.com/store/apps/details?id=abcdf&referrer=RefID

In the script I need to get RefID, but I don’t know how to do it.

I searched for information on Google for several days, but without result. Because the information is old or it is not possible to integrate into Unity.

6741043--776845--upload_2021-1-19_19-3-0.png

To clarify, you already have the URL in the script, and you just need to extract the referrer parameter from it?

2 Likes

I will clarify.
This referral parameter is generated on the web server after the first launch of the game in the play market.
When a user shares a referral link and another user downloads the game from the link provided.
I need to ask the Play Market if the referral parameter exists or not.
But I don’t know how to do it

It doesn’t appear that there is a built-in way to do this, so you will need to retrieve the referrer from Java. I found a guide to retrieve referrer information: Android Developers Blog: Google Play Referrer API: Track and measure your app installs easily and securely

And there is a Unity guide on how to execute custom Java code here: Unity - Manual: Extending the UnityPlayerActivity Java Code

2 Likes

I read the latest version of this guide here: https://developer.android.com/google/play/installreferrer/library.html

The problem is that the api will work after connecting the library in the build.gradle file. But it doesn’t work in Unity. I reviewed all the documentation on this api and I could not find how to make it work in Unity.

But, I did not stop and continued the search. Found an interesting solution on GitHub:https://github.com/uerceg/play-install-referrer-unity#api-playinstallreferrer

I can’t test this solution because I just started developing the game and I don’t know if it will work, but it looks good.

That’s because it doesn’t work in unity. You need to execute it on the Java side of things:

Looks like that may work for you. Seems there’s a unity utility that allows you to interop with Java code: https://docs.unity3d.com/ScriptReference/AndroidJavaClass.html

1 Like

Madgvox, thanks for the links. I read the documentation. Now I have a lot of questions :slight_smile: Probably I’ll use the solution from the github.

The problem is not the interaction between Unity and Java code. The documentation contains code that can be adapted for Unity. There is no documentation or guide on how to integrate this library / api in Unity and this is a mistake of the developers of this api.
Thank you for your help! Good luck!

@jurec4512 Its been a while. Did you manage to make it work?

1 Like