Deep Linking Firebase

What is deep linking?

Deep links are a type of link that sends users directly to an app instead of a website or a store. They are used to send users straight to specific in-app locations, saving users the time and energy locating a particular page themselves – significantly improving the user experience.

 

Deep linking does this by specifying a custom URL scheme (iOS Universal Links) or an intent URL (on Android devices) that opens your app if it’s already installed. Deep links can also be set to direct users to specific events or pages, which could tie into campaigns that you may want to run.

 

Why are the deep links important?

Deep links produce a seamless user journey that reduces churn and increases the likelihood of an install. They let you make sophisticated campaigns while providing a better user experience, moving users onto your app in a single click.

 

Deep links also create the opportunity for easier incentivization. It’s simple to persuade people to try a new experience when a potential prize or offer is sent to them via a retargeting campaign.

 

For example, let’s say you have a music app and want to promote a new album, so you allocate budget to be spent on a popular website. However, you want the user to listen to the sample in-app, not just on the website (where they are only exposed to the album cover). Here you need a deep link to send them directly to the correct page in your app, offering a seamless user experience.

 

In-app deep linking can significantly increase your conversion rate and retention rate. Deep linking campaigns can be tracked, and provide extra data points on how your campaign performs. If you’d like to learn more about this, you can read up on the effects of deep linking in campaigns  here.

 

There are 2 ways to do deep linking,

1 – Normal way

2 – Firebase based Deeplinking

Here I am going to explain to you how to implement deeplinking using firebase,

 

Firebase Dynamic Links

Firebase Dynamic Links are links that work the way you want, on multiple platforms, and whether or not your app is already installed.

 

With Dynamic Links, your users get the best available experience for the platform they open your link on. If a user opens a Dynamic Link on iOS or Android, they can be taken directly to the linked content in your native app. If a user opens the same Dynamic Link in a desktop browser, they can be taken to the equivalent content on your website.

 

In addition, Dynamic Links work across app installations: if a user opens a Dynamic Link on iOS or Android and doesn’t have your app installed, the user can be prompted to install it; then, after installation, your app starts and can access the link.

 

How does it work?

You create a Dynamic Link either by using the Firebase console, using a REST API, iOS or Android Builder API, or by forming a URL by adding Dynamic Link parameters to a domain specific to your app. These parameters specify the links you want to open, depending on the user’s platform and whether your app is installed.

 

When a user opens one of your Dynamic Links, if your app isn’t yet installed, the user is sent to the Play Store or App Store to install your app (unless you specify otherwise), and your app opens. You can then retrieve the link that was passed to your app and handle the deep link as appropriate for your app.

 

Custom link domains

You can Create Dynamic Links using your own domain name:

https://example.com/summer-sale

https://example.com/links/promos/summer-sale

https://links.example.com/summer-sale

https://ex.amp.le/summer-sale

Or, if you don’t have a domain for your app, you can use a no-cost custom page.link subdomain:

https://example.page.link/summer-sale

Create your subdomain at no charge in the Firebase console.

All Dynamic Links features, including analytics, post-install attributions, and SDK integrations, work with both custom page.link domains and your own domain.

 

Implementation path:

  • Set up Firebase and the Dynamic Links SDK: Enable Firebase Dynamic Links for your Firebase project in the Firebase console. Then, include the Dynamic Links SDK in your app. If you are working with IOS/Android project then we need to add this project in our firebase project.
  • Create Dynamic Links : You can create Dynamic Links programmatically or by using the Firebase console.
  • Handle Dynamic Links in your app : When your app opens, use the Dynamic Links SDK to check if a Dynamic Link was passed to it. If so, get the deep link from the Dynamic Link data and handle the deep link as necessary.
  • View analytics data : Track the performance of your Dynamic Links in the Firebase console. When you are adding the deep URL using firebase at that time you need to choose an option like you need to open this link in web or app. If you choose web it will open in web else open app. If app is not there it will open in App store/Play store.

Create Dynamic Links with the REST API

You can create short Dynamic Links with the Firebase Dynamic Links REST API. This API accepts either a long Dynamic Link or an object containing Dynamic Link parameters, and returns a URL like the following example:

https://example.page.link/WXYZ

 

Short Dynamic Links created with the API and client (Android/Apple) SDK do not show up in the Firebase console. Such Dynamic Links are intended for user-to-user sharing. For marketing use cases, continue to create your links directly through the Dynamic Links page of the Firebase console.

 

Before you begin

  1. Get your API key. You will need an API key to authenticate your requests to the API. To find your API key:
  2. Open the Settings page of the Firebase console. If you are prompted to choose a project, select your Firebase project from the menu.
  3. Take note of the value of the Web API Key  field.
  4. In the Firebase console, open the Dynamic Links section.
  5. If you have not already accepted the terms of service and set a domain for your Dynamic Links, do so when prompted.

If you already have a Dynamic Links domain, take note of it. You need to provide a Dynamic Links domain when you programmatically create Dynamic Links.

 

Creating a short Dynamic Link from long link

You can use the Firebase Dynamic Links API to shorten a long Dynamic Link. To do so, make an HTTP POST request to the short Links endpoint, specifying the long Dynamic Link in the longDynamicLink parameter.

For example:

POST https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=api_key

Content-Type: application/json

{

   “longDynamicLink”: “https://example.page.link/?link=https://www.example.com/&apn=com.example.android&ibi=com.example.ios”

}

See  Manually construct a URL to learn how to create long Dynamic Links.

 

Create a short link from parameters

You can also create a short Dynamic Link by specifying the Dynamic Link parameters directly. To do so, make an HTTP POST request to the shortLinks endpoint, specifying the Dynamic Link parameters in the dynamicLinkInfo parameter. For example:

POST https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=api_key

Content-Type: application/json

{

  “dynamicLinkInfo”: {

    “domainUriPrefix”: “https://example.page.link”,

    “link”: “https://www.example.com/”,

    “androidInfo”: {

      “androidPackageName”: “com.example.android”

    },

    “iosInfo”: {

      “iosBundleId”: “com.example.ios”

    }

  }

}

We can get the API key from the console. Without API key we cannot get response. This API is used when we need a deep link URL.

We can get the android package name and iosBundleId from the App team once the project is public or create the demo on firebase.
After getting those details we need to add in the above code.

 

I hope you liked this article; I will be grateful if you add your input in comment including any technical step I’m missing, I will try to cover if I get it in input.

 

Have a happy reading!!!

 

Leave a Reply

Your email address will not be published. Required fields are marked *