Example of Android Mobile Deep links indexing by search engine

By | December 11, 2015

To continue our topic of Mobile Deep links, today we’ll explain how we did those deep links indexed by Google search engine.

What is a app indexing?

In order to make life easier for users, Google provides such opportunity as indexing applications. With this feature, the user can easily switch between the browser and native applications. To use this, the developer needs to add a link to an application on its website.

When searching in Google using keywords where our app is ranked well, we can see it in search results in the form:

Example of Android Mobile Deep links indexing by search engine

And if the application has not been installed on our device, then by clicking on it, we will be redirected to Play Market for download.

Example of Android Mobile Deep links indexing by search engine

How to add links to web site?

You can place links to your app in your website. There are three ways to inform Google’s robots on the connection between a web page and a link to the application content:

  • add a <Link> element in the section <head>;
  • add a <xhtml:link>, pointing to a page in the element <url> File Sitemap;
  • use App Indexing API.

In the latter case it would work with AutoComplete.

<Link> element allows you to specify an alternate URI (specified in the attribute href), in which you can open the content in the application. It has the following format:

android-app:// <package_id> / <scheme> / <host_path>

Test of properly formatted android-app:// can be accessed here.

To link rel = alternate to html page code you need to add

<html>
	<head>
		...
		<link rel="alternate" href="android-app://com.ex-app/http/ex-app-host.com/register" />
		...
	</head>
	<body> … </body>

If you use the scheme without http, then

<html>
	<head>
		...
		<link rel="alternate" href="android-app://com.ex-app/ex-app-client/ClientRegister" />
		...
	</head>
	<body> … </body>

Now we need to bind the rel = alternate file in XML-Sitemap:

<?xml version="1.0" encoding="UTF-8" ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
	<url>
		<loc>http://web.ex-app.com/register</loc>
		<xhtml:link rel="alternate" href="android-app://com.ex-app/ex-app-client/register" />
	</url>
	...
</urlset>

And the last step would be to update the robots.txt file on our server. When Google indexes content applications, it sends HTTP-requests, and our servers should allow requests from Googlebot. For that you need to edit the robots.txt file on the server. For example:

User-Agent: Googlebot
Allow: /

How to add exceptions in links?

Suppose that we have links that include the name of our host + our pathPrefix + something else. For example, http://web.ex-app.com/register/newuser. But we don’t want them indexed or processed by Google. What to do in this case? We need to create in our resource directory file noindex.xml, and put there few lines of code:

<?xml version="1.0" encoding="utf-8"?>
<search-engine xmlns:android="http://schemas.android.com/apk/res/android">
	<noindex uri="http://ex-app-host.com/register/newuser"/>
	<noindex uriPrefix="http://ex-app-host.com/register/newuser"/>
	<noindex uri="ex-app://register/newuser"/>
	<noindex uriPrefix="ex-app://register/newuser"/>
</search-engine>

uri – indicates exact match, and uriPrefix – denotes something with which we can start URL.

Next, we need to add few change in the Manifest.xml. To Google to keep track of these we need to add URL

<meta-data android:name="search-engine" android:resource="@xml/noindex"/>

to the <application> level.

It will look like:

<application ..>
	<activity>
		<intent-filter>...</intent-filter>
	</activity>
	...
	<meta-data android:name="search-engine" android:resource="@xml/noindex"/>
	...
</application>

Now we have App Deep Links indexed by Google!

As always, feel free to contact us for a consultation!

Leave a Reply

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