Zur Konsole

提升应用在搜索结果中的排名

通过内容创作和效果分析等手段,提升您的应用在 Google 搜索中的排名。

借助搜索引荐信息进行分析

您可以从 Google 搜索指向您应用的链接中提取引荐来源信息,并将这些信息用于其他分析工具。例如,我们的代码实验室中关于跟踪应用引荐的主题介绍了如何将搜索引荐与 Google Analytics(分析)结合使用,从而对应用进行全面的分析。

如需构建自己的解决方案来跟踪应用的搜索流量,您可以使用 Android 调试桥向您的应用传递一个测试 android.intent.extra.REFERRER_NAME extra。下面的示例命令演示了如何执行此操作,该示例假设您应用的软件包名称为 package_name,且应用的网址为 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

此测试模拟的场景为:在您的应用中打开一个 HTTP 网址,并传入引荐来源信息(指明流量来自 Google 应用)。

提取引荐来源信息

com.google.firebase.appindexing.AndroidAppUri 类可帮助提取引荐来源网址 URI。您可使用一个意图 extra 使用以下键提供 HTTP 网址的引荐来源网址信息:android.intent.extra.REFERRER_NAME

以下示例显示了来自各种源的引荐来源值:

  • Chromehttps://www.google.com
  • Google 应用 android-app://com.google.android.googlequicksearchbox/https/www.google.com
  • Googlebotandroid-app://com.google.appcrawler
  • Google AdsBot App Crawlerandroid-app://com.google.adscrawler

下面这段代码演示如何提取源自 Google 搜索的引荐来源信息。

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

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
                    // ...
                }
            }
        }
        // ...
    }
}

创作优质的网页和移动内容

您可以同时在应用和关联网站上提供优质内容,以提升应用的排名。这是因为我们的系统会分析这两种媒体资源之间的关联,进而确定 Web 和移动搜索结果的排名。特别要牢记以下几点:

  • 确保您的关联网站符合我们的设计和内容准则
  • 遵循移动网站搜索引擎优化指南中建议的做法。

为了确保向用户提供出色的搜索体验,如发现滥用、欺诈或其他损害用户搜索体验的行为,Google 可能会采取纠正措施。这些措施可能包括对您的 HTTP 网址进行降位,或将其从 Google 搜索结果中移除。