Improve your app's ranking in Google Search, from content creation through performance analysis.
Analyze with Search referrals
You can use the referrer information from links to your app that come from Google Search for other analytics tools.
To build your own solution for tracking Search traffic to
your app, you can pass a test android.intent.extra.REFERRER_NAME
to your app using the Android Debug Bridge. The following example
command demonstrates how to do this, assuming your app's package name is
package_name and your app URL is www.examplepetstore.com
:
adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -e android.intent.extra.REFERRER_NAME android-app://com.google.android.googlequicksearchbox/https/www.examplepetstore.com -d http://examplepetstore.com/host_path com.examplepetstore.android
This test simulates opening a HTTP URL in your app and passing in referrer information specifying that the traffic came from the Google app.
Extract Referrer Information
The
com.google.firebase.appindexing.AndroidAppUri class helps with
extracting referrer URIs. An Intent extra provides the referrer information
for your HTTP URL with the following key:
android.intent.extra.REFERRER_NAME
.
The following examples show referrer values from various sources:
- Chrome:
https://www.google.com
- Google app:
android-app://com.google.android.googlequicksearchbox/https/www.google.com
- Googlebot:
android-app://com.google.appcrawler
- Google AdsBot App Crawler:
android-app://com.google.adscrawler
The following code snippet shows how to extract referrer information from Search.
Java
public class MeasureActivity extends AppCompatActivity { @Override public Uri getReferrer() { // There is a built in function available from SDK>=22 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { return super.getReferrer(); } Intent intent = getIntent(); Uri referrer = (Uri) intent.getExtras().get("android.intent.extra.REFERRER"); if (referrer != null) { return referrer; } String referrerName = intent.getStringExtra("android.intent.extra.REFERRER_NAME"); if (referrerName != null) { try { return Uri.parse(referrerName); } catch (ParseException e) { // ... } } return null; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ... Uri referrer = getReferrer(); if (referrer != null) { if (referrer.getScheme().equals("http") || referrer.getScheme().equals("https")) { // App was opened from a browser // host will contain the host path (e.g. www.google.com) String host = referrer.getHost(); // Add analytics code below to track this click from web Search // ... } else if (referrer.getScheme().equals("android-app")) { // App was opened from another app AndroidAppUri appUri = AndroidAppUri.newAndroidAppUri(referrer); String referrerPackage = appUri.getPackageName(); if ("com.google.android.googlequicksearchbox".equals(referrerPackage)) { // App was opened from the Google app // host will contain the host path (e.g. www.google.com) String host = appUri.getDeepLinkUri().getHost(); // Add analytics code below to track this click from the Google app // ... } else if ("com.google.appcrawler".equals(referrerPackage)) { // Make sure this is not being counted as part of app usage // ... } } } // ... } }
Kotlin+KTX
class MeasureActivity : AppCompatActivity() { override fun getReferrer(): Uri? { // There is a built in function available from SDK>=22 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { return super.getReferrer() } val intent = intent val referrer = intent?.extras?.get("android.intent.extra.REFERRER") as Uri? if (referrer != null) { return referrer } val referrerName = intent.getStringExtra("android.intent.extra.REFERRER_NAME") if (referrerName != null) { try { return Uri.parse(referrerName) } catch (e: ParseException) { // ... } } return null } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // ... val referrer = referrer if (referrer != null) { if (referrer.scheme == "http" || referrer.scheme == "https") { // App was opened from a browser // host will contain the host path (e.g. www.google.com) val host = referrer.host // Add analytics code below to track this click from web Search // ... } else if (referrer.scheme == "android-app") { // App was opened from another app val appUri = AndroidAppUri.newAndroidAppUri(referrer) val referrerPackage = appUri.packageName if ("com.google.android.googlequicksearchbox" == referrerPackage) { // App was opened from the Google app // host will contain the host path (e.g. www.google.com) val host = appUri.deepLinkUri.host // Add analytics code below to track this click from the Google app // ... } else if ("com.google.appcrawler" == referrerPackage) { // Make sure this is not being counted as part of app usage // ... } } } // ... } }
Create Good Web & Mobile Content
You can enhance your app's ranking by providing high-quality content in both your app and your associated website. This is because our systems analyze the association between the two properties to determine ranking for both web and mobile Search results. Specifically, keep in mind the following:
- Make sure your associated site meets our design and content guidelines.
- Follow the same practices recommended in our Mobile SEO guide.
In order to ensure a great search experience for users, Google may take corrective action in cases where we see abuse, deception, or other actions that hurt the search experience for users. This can include actions such as demoting or removing your HTTP URLs from Google Search results.