开始使用安全信号
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
安全信号是在客户端设备上收集并与所选出价方共享的编码数据。本指南介绍了如何使用 IMA SDK 收集安全信号并将其发送到 Google Ad Manager。
安全信号 API 需要使用 3.29.0 或更高版本的 IMA SDK for Android。
如需选择信号和出价方并启用安全信号共享,请参阅与出价方共享安全信号。
使用第三方信号提供商
如需使用安全信号,您必须在应用中部署信号收集器适配器类,以收集信号、对其进行编码,然后将其传递给 IMA SDK。
按照第三方提供商的说明,在他们那里设置账号、添加 build 依赖项,并在您的应用中设置他们的安全信号适配器。
Android 版 IMA SDK 会自动初始化每个安全信号适配器,而无需对代码进行任何额外更改。
以下示例展示了如何向项目添加安全信号适配器:

发送自定义数据
除了使用第三方信号提供商之外,您还可以收集、编码和发送包含自定义数据的信号。您必须先在 Ad Manager 中启用自定义信号,然后才能发送包含自定义数据的安全信号。
针对每个广告请求,创建一个 SecureSignals
对象,其中包含编码后的自定义数据(以字符串形式)。然后,通过调用 adsRequest.setSecureSignals()
将 SecureSignals
对象添加到广告请求中。
以下是一个 Java 示例:
app/src/main/java/com/example/project name/MainActivity.java
...
private void requestAds(String adTagUrl) {
// Create the ads request.
AdsRequest request = sdkFactory.createAdsRequest();
request.setAdTagUrl(adTagUrl);
request.setContentProgressProvider(
() -> {
if (videoPlayer.getDuration() <= 0) {
return VideoProgressUpdate.VIDEO_TIME_NOT_READY;
}
return new VideoProgressUpdate(
videoPlayer.getCurrentPosition(), videoPlayer.getDuration());
});
SecureSignals signal = SecureSignals.create("My encoded signal string");
request.setSecureSignals(signal);
// Request the ad. After the ad is loaded, onAdsManagerLoaded() will be called.
adsLoader.requestAds(request);
}
...
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-31。
[null,null,["最后更新时间 (UTC):2025-08-31。"],[[["\u003cp\u003eSecure signals, encoded data from user devices, are shared with select bidders to enhance ad targeting.\u003c/p\u003e\n"],["\u003cp\u003eThe IMA SDK facilitates collecting and sending these signals to Google Ad Manager, requiring version 3.29.0 or higher for Android.\u003c/p\u003e\n"],["\u003cp\u003eIntegration involves using a third-party signal provider's adapter or sending custom data, which requires enabling the feature in Ad Manager.\u003c/p\u003e\n"],["\u003cp\u003ePublishers can share these signals with specific bidders via the Ad Manager interface to improve ad relevance and performance.\u003c/p\u003e\n"]]],[],null,["# Get started with secure signals\n\nSecure signals are encoded data that is collected on the client device and\nshared with select bidders. This guide shows you how to collect and send secure\nsignals to Google Ad Manager using the IMA SDK.\n\nThe secure signals API requires version 3.29.0\nor higher of the IMA SDK for Android.\n\nTo select signals and bidders, and enable secure signal sharing, see [Share\nsecure signals with bidders](//support.google.com/admanager/answer/10488752).\n\nUse a third-party signal provider\n---------------------------------\n\nTo use secure signals, you must deploy a signal collector\n\nadapter class in your app\n\nto collect signals, encode them, and pass them to the IMA SDK.\n\n\u003cbr /\u003e\n\nFollow your third-party provider's instructions to set up an account with them,\n\n[add build dependencies](//developer.android.com/studio/build/dependencies#google-maven),\n\nand set up their secure signals adapter in your app.\n\nThe IMA SDK for Android automatically\ninitializes each secure signals adapter, without any additional changes to your\ncode.\n\nHere's an example of how you might add a secure signals adapter to your project:\n\n\nSend custom data\n----------------\n\nIn addition to using a third-party signal provider, you can also collect,\nencode, and send signals with custom data. Before you can send secure signals\nwith custom data, you must turn on custom signals in Ad Manager.\n\nFor each ad request, create a `SecureSignals` object containing your encoded\ncustom data, as a string. Then, add the `SecureSignals` object to your ad\nrequest by calling `adsRequest.setSecureSignals()`.\n\nHere's a java example:\n\n**app/src/main/java/com/example/project name/MainActivity.java** \n\n ...\n private void requestAds(String adTagUrl) {\n // Create the ads request.\n AdsRequest request = sdkFactory.createAdsRequest();\n request.setAdTagUrl(adTagUrl);\n request.setContentProgressProvider(\n () -\u003e {\n if (videoPlayer.getDuration() \u003c= 0) {\n return VideoProgressUpdate.VIDEO_TIME_NOT_READY;\n }\n return new VideoProgressUpdate(\n videoPlayer.getCurrentPosition(), videoPlayer.getDuration());\n });\n SecureSignals signal = SecureSignals.create(\"My encoded signal string\");\n request.setSecureSignals(signal);\n // Request the ad. After the ad is loaded, onAdsManagerLoaded() will be called.\n adsLoader.requestAds(request);\n }\n ..."]]