0

I want to add a link to a webpage that, when clicked, either deep links to the correct page in an app or, if the user does not have the app installed, redirects to the Google Play Store. In this case, I want to send referrer data that can be collected in Google Analytics.

I know both are possible, but I don't know how they are used together. I'm trying to combine Android browser intents as described here with Google Play Campaign Attribution described here.

Is this possible? How?

Borre Mosch
  • 4,404
  • 2
  • 19
  • 28
  • I believe your best course of action on this case is to detect on runtime if the app is installed http://stackoverflow.com/questions/3922606/detect-an-application-is-installed-or-not and then launch the appropriate intent based on it. – Budius Nov 13 '14 at 14:49
  • This would only work if I were trying to start the app from another app. I am trying to launch the app from the webbrowser. As far as I know, there is no way to detect whether an app is installed from the browser. This would be a severe privacy risk. – Borre Mosch Nov 13 '14 at 15:03
  • the app in question is controlled by you (or your dev team), or is it a 3rd party app ? (if your own app, I'll suggest what we've done at my company) – Budius Nov 13 '14 at 15:09
  • Yes it is controlled by us, as is the website that I need the URL for. – Borre Mosch Nov 13 '14 at 15:14
  • I know this is a late answer but thought it may help someone else. I found its really easy to do both with Branch Deeplink SDK – Sojan P R Sep 02 '15 at 18:24

1 Answers1

1

so based on our comments my suggestion (it's somewhat what we've done our app): you still have to have different separates links (one for Google Play and one for app, with their respective meta-datas), but with a little bit of hackery it works.

the browser gives the link: www.myapp.com/open (with any extra parameter you might need) and one of the app activities you implement the intent filter

  <intent-filter>
     <data
        android:host="www.myapp.com"
        android:pathPrefix="/open"
        android:scheme="http"/>

     <action android:name="android.intent.action.VIEW"/>

     <category android:name="android.intent.category.BROWSABLE"/>
     <category android:name="android.intent.category.DEFAULT"/>
  </intent-filter>

this will open your app from the browser, where you can deep-link and/or pass any parameters necessary encoded in the URL. ps. for safety also add filters for m.myapp.com, myapp.com and https or any other relevant variation

but, if the user does not have the app and the browser will actually try to load the URL www.myapp.com/open then the response from this URL will redirect it to https://play.google.com/store/apps/details?id=com.myapp.awesomeness (with any extra referrer meta-data you want to add to it.

it's a little bit hackery, but it works.

Hope it helps.

Budius
  • 39,391
  • 16
  • 102
  • 144
  • I'll +1 your answer for the effort. However, I won't be able to use this solution for three reasons. First, the URL scheme was set up a long time ago. The web server is set up to serve the web version of the content, so I cannot add a redirect there. Second, the source and destination URL are both on the same domain. In this case, Chrome will open the destination URL in the browser. Third, even if the URLs were not on the same domain, there would be a pop-up the first time the link is clicked asking the user whether they want to open the URL in the browser or in the app. – Borre Mosch Nov 13 '14 at 15:34
  • 1
    just a follow up to your comments: 1st: for us as well, we had to roll the app update and wait for users to have the new version (sad-but-true), regarding the server I'm not sure how the frontend guys did, I'm Android dev. 2nd: ours are also on the same domain, that doesn't stop the thing from working, what makes the difference here is having an appropriate `pathPrefix`. 3rd is indeed. You'll be loosing the direct Chrome intent. But I don't see any other workaround. Anyway, good luck on your quest! – Budius Nov 13 '14 at 15:45