整合安全信號轉接器
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
安全信號是從用戶端裝置收集並與特定出價方共用的編碼資料。本指南說明如何使用 IMA SDK 收集安全信號,並傳送至 Google Ad Manager。
如要選取信號和出價方,並啟用安全信號共用功能,請參閱「與出價方共用安全信號」。
使用第三方信號供應商
如要使用安全信號,請務必在網站上部署信號收集器指令碼,收集信號、編碼,然後傳遞至 IMA SDK。
您可以自動或手動部署安全信號指令碼。
自動部署
在 Ad Manager 中選取信號供應商時,視所選信號供應商而定,您可能會看到「請 Google 代您部署信號收集指令碼」選項。如果選取這個選項,且網站包含 Google 發布商廣告代碼,系統就會自動載入您選擇的信號收集器指令碼。
以下是您在 Ad Manager 使用者介面中可能看到的內容:

以下是網站 index.html
檔案的範例:
<script src="//imasdk.googleapis.com/js/sdkloader/ima3.js"></script>
<!-- Load gpt.js, which autoloads all signal provider scripts configured to be
deployed by Google. -->
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
<script src="ads.js"></script>
手動部署
如果 Ad Manager 中沒有「請 Google 代表您部署信號收集指令碼」選項,或您未開啟這個選項,則必須向安全信號供應商取得指令碼連結,並手動將連結加入專案。
以下是您在 Ad Manager 使用者介面中可能看到的內容:

以下是網站 index.html
檔案的範例:
<script src="//imasdk.googleapis.com/js/sdkloader/ima3.js"></script>
<!-- Load signal provider scripts manually, using the unique instructions given by each
signal provider. -->
<script src="//cdn.provider1.com/files/a/e/5/4/7/signalCollector.js"></script>
<script src="//provider2.co.uk/ads/signalcollector/script.min.js"></script>
<script src="/local/path/to/third_party_signal_provider_3.js"></script>
<script src="ads.js"></script>
傳送自訂資料
除了使用第三方信號供應商,您也可以收集、編碼及傳送信號和自訂資料。如要傳送含有自訂資料的安全信號,請務必先在 Ad Manager 中啟用自訂信號。
HTML5 專案的步驟如下:
- 建立具有下列屬性的物件:
networkCode
和 collectorFunction
。
- 在
networkCode
屬性中填入聯播網代碼。
- 在
collectorFunction
屬性中填入函式,該函式會傳回可解析為編碼信號的 Promise。
在例項化 adsLoader
之前,請將物件推送至 googletag.secureSignalProviders
陣列,讓 IMA SDK 能夠存取該物件,以擷取及傳輸編碼信號:
以下是 JavaScript 範例:
console.log("initializing IMA");
adContainer = document.getElementById('ad-container');
adDisplayContainer = new google.ima.AdDisplayContainer(adContainer, videoElement);
const NETWORK_CODE = '21775744923';
/**
* Sample signal collector function.
* @return {!Promise<string>} A promise that resolves to the encoded signals.
*/
const signalCollector = () => {
return new Promise((resolve, reject) => {
resolve("My encoded signal string");
});
};
if (!googletag) googletag = {};
if (!googletag.secureSignalProviders) googletag.secureSignalProviders = [];
googletag.secureSignalProviders.push({
networkCode: NETWORK_CODE,
collectorFunction: signalCollector
});
adsLoader = new google.ima.AdsLoader(adDisplayContainer);
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[null,null,["上次更新時間:2025-08-31 (世界標準時間)。"],[[["\u003cp\u003eSecure signals are encoded data collected on devices and shared with specific bidders to enhance ad targeting.\u003c/p\u003e\n"],["\u003cp\u003eYou can deploy secure signal scripts automatically through Google Ad Manager or manually by including provider scripts in your project.\u003c/p\u003e\n"],["\u003cp\u003eCustom data can be sent as secure signals using a collector function that returns encoded signals, after enabling the feature in Ad Manager.\u003c/p\u003e\n"],["\u003cp\u003eTo utilize secure signals, you need to implement a signal collector script for data collection, encoding, and transmission to the IMA SDK.\u003c/p\u003e\n"]]],[],null,["# Integrate secure signals adapters\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\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\nscript on your site\n\nto collect signals, encode them, and pass them to the IMA SDK.\n\nYou deploy secure signals scripts either automatically or manually.\n\n### Deploy automatically\n\nWhen selecting signal providers in Ad Manager, depending on your selected signal\nproviders, you might get the option to **Ask Google to deploy the signal\ncollection script on your behalf** . If you select this option, and your site\nincludes [Google Publisher Tags](/publisher-tag/guides/get-started), the signal\ncollector scripts you chose are loaded automatically.\n\nHere's an example of what you might see in the [Ad Manager\nUI](//admanager.google.com/):\n\nHere's an example of what you might see in your site's `index.html` file: \n\n \u003cscript src=\"//imasdk.googleapis.com/js/sdkloader/ima3.js\"\u003e\u003c/script\u003e\n \u003c!-- Load gpt.js, which autoloads all signal provider scripts configured to be\n deployed by Google. --\u003e\n \u003cscript async src=\"https://securepubads.g.doubleclick.net/tag/js/gpt.js\"\u003e\u003c/script\u003e\n \u003cscript src=\"ads.js\"\u003e\u003c/script\u003e \n https://github.com/googleads/googleads-ima-html5/blob/857dd5019edba73ca0bd50046ae6a739fa4cd70b/doc_snippets/secure_signals/auto_load.html#L8-L12\n\n### Deploy manually\n\nIf you don't see the option **Ask Google to deploy the signal collection script\non your behalf** in Ad Manager or if you don't turn on this option, you need to\nget a script link from your secure signals provider and manually include it in\nyour project.\n\nHere's an example of what you might see in the [Ad Manager\nUI](//admanager.google.com/):\n\nHere's an example of what you might see in your site's `index.html` file: \n\n \u003cscript src=\"//imasdk.googleapis.com/js/sdkloader/ima3.js\"\u003e\u003c/script\u003e\n \u003c!-- Load signal provider scripts manually, using the unique instructions given by each\n signal provider. --\u003e\n \u003cscript src=\"//cdn.provider1.com/files/a/e/5/4/7/signalCollector.js\"\u003e\u003c/script\u003e\n \u003cscript src=\"//provider2.co.uk/ads/signalcollector/script.min.js\"\u003e\u003c/script\u003e\n \u003cscript src=\"/local/path/to/third_party_signal_provider_3.js\"\u003e\u003c/script\u003e\n \u003cscript src=\"ads.js\"\u003e\u003c/script\u003e \n https://github.com/googleads/googleads-ima-html5/blob/857dd5019edba73ca0bd50046ae6a739fa4cd70b/doc_snippets/secure_signals/manual_load.html#L8-L14\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\nHere are the steps for HTML5 projects:\n\n1. Create an object with these properties: `networkCode` and `collectorFunction`.\n2. Populate the `networkCode` property with your [network code](//support.google.com/admanager/answer/7674889).\n3. Populate the `collectorFunction` property with a function that returns a promise that resolves to your encoded signals.\n\nPush the object to the `googletag.secureSignalProviders` array before\ninstantiating your `adsLoader` so that the IMA SDK can access it to retrieve and\ntransmit your encoded signals:\n\nHere's a javascript example: \n\n console.log(\"initializing IMA\");\n adContainer = document.getElementById('ad-container');\n adDisplayContainer = new google.ima.AdDisplayContainer(adContainer, videoElement);\n\n const NETWORK_CODE = '21775744923';\n\n /**\n * Sample signal collector function.\n * @return {!Promise\u003cstring\u003e} A promise that resolves to the encoded signals.\n */\n const signalCollector = () =\u003e {\n return new Promise((resolve, reject) =\u003e {\n resolve(\"My encoded signal string\");\n });\n };\n if (!googletag) googletag = {};\n if (!googletag.secureSignalProviders) googletag.secureSignalProviders = [];\n googletag.secureSignalProviders.push({\n networkCode: NETWORK_CODE,\n collectorFunction: signalCollector\n });\n\n adsLoader = new google.ima.AdsLoader(adDisplayContainer); \n https://github.com/googleads/googleads-ima-html5/blob/857dd5019edba73ca0bd50046ae6a739fa4cd70b/doc_snippets/secure_signals/auto_load.js"]]