Hotwire Tech Blog

Scribes from Hotwire Engineering

Introduction

Typically, when users search for content using Google Search on their mobile devices, they are directed to the corresponding mobile web page or in some cases the actual web page itself.

This often leads to a sub-optimal user experience mainly because mobile users are limited by screen size and processing power. Also web pages have multiple scripts executing on load which sometimes render the screen inactive for intermittent periods of time.

App indexing on the other hand, gets the app into search results. If the app is already installed on the user’s phone, the app is directly launched from the search results or in cases where the user does not have the app, shows an install card as a part of the results prompting the user to install the app – thus promoting the native install base and offer a better user experience on mobile devices.

Screen Shot 2016-06-19 at 8.23.07 AM Screen Shot 2016-06-19 at 8.30.09 AM

Specifying App Content for Indexing

Google’s web crawling bot (Googlebot), which crawls and indexes web sites for the Google search engine, can also index content in your Android app. To indicate which app content you’d like Google to index, simply add link elements either to your existing Sitemap file or in the  element of each web page in your site, in the same way as you would for web pages.

The deep links that you share with Google Search must take this URI format:

Screen Shot 2016-06-19 at 9.54.50 AM

The components that make up the URI format are:

1. package_name. Represents the package name for your APK as listed in the Google Play Developer Console.
2. scheme. The URI scheme that matches your intent filter.
3. host_path. Identifies the specific content within your application.

In our case being –

Screen Shot 2016-06-19 at 10.01.36 AM

Declaring a Website Association –

You can annotate the deep links in the HTML markup of your web pages. You can do this in the <head> section for each web page by adding a tag and specifying the deep link as an alternate URI. The end result would look something like this –

Adding an Intent filter to the Android App – 

Once the website association is in place, you would need to add an intent filter into the AndroidManifest.xml to handle the corresponding scheme and launch the app.

Screen Shot 2016-06-19 at 9.11.53 AM

 

Handling the Intent – 

Now that you have handled the intent and have launched the app, you can perform specific actions based on the intent data (which is the deeplink) – such as firing a specific activity, launch a hotel search etc.

Screen Shot 2016-06-19 at 9.23.55 AM

 

Fetch and Render from the Google Search console – 

Once all the code for the App indexing is in place, you have to make sure that Google can actually crawl the web page for which you created an association.
Since you are opening the search results from a mobile phone, you need to do a Fetch and Render as Mobile:Smartphone. (*will be soon replaced by Google Smartphone crawler)

It would look like this –

Screen Shot 2016-06-19 at 9.34.05 AM

 

A Fetch and Render should show –

Screen Shot 2016-06-19 at 9.37.30 AM

*Partial indicates that some elements in the page are blocked from the crawler – which is fine.

Conclusion

As result of the above steps, Google should crawl the webpage soon and for specific webpages, the app content is now indexed and as a result will open the app for this specific search result.

There are a couple of different ways to index content in your app – other techniques being to support HTTP URLs in the app and launch specific activities based on the URLs passed to it. But if the app is not configured to support HTTP urls to begin with, this is an excellent alternative approach.