設定 TrustArc 以取得使用者同意聲明

如要擷取有價值的洞察資料,同時保護使用者隱私,您需要取得網站使用者的同意聲明。建議您使用同意聲明管理平台 (CMP) 或內容管理系統 (CMS),收集同意聲明並將資料傳送給 Google。

步驟 1:設定同意橫幅

  1. 如果您使用 CCM Advanced (代管服務),客戶技術顧問 (TAM) 會根據您的需求和樣式規範設定橫幅。
  2. 如果您使用 CCM Pro (自助式 CMP),TrustArc 會提供網址讓您登入入口網站,並使用精靈中預先定義的範本設定橫幅。
  3. 確認您的橫幅符合《Google 歐盟地區使用者同意授權政策》的規定。如要進一步瞭解 TrustArc 橫幅設定,請參閱《使用手冊》中的「開始使用」一節
  4. 在網站程式碼中或透過 Google 代碼管理工具加入 <div> 元素,用以顯示橫幅和 CMP 連結。

步驟 2:設定同意聲明模式

使用 Google 代碼管理工具

  1. 開啟代碼管理工具,然後前往您的容器。
  2. 在「代碼」中按一下「新增」,然後為代碼命名。
  3. 按一下「代碼設定」,然後點選「探索社群範本庫的其他代碼類型」。在範本庫中搜尋「TrustArc CMP (Consent Mode)」,然後安裝 TrustArc 的「TrustArc CMP (Consent Mode)」。
  4. 在「Default Consent Mode settings」(預設同意聲明模式設定) 下方,設定您要使用的預設設定。
  5. 選取「Deploy CMP Script using the template」(使用範本部署 CMP 指令碼) 選項。
    1. 在「CMP ID」欄位中,輸入 CCM Pro 入口網站「Step 4. Copy Code Snippet」(步驟 4:複製程式碼片段) 提供的執行個體 ID。如果您使用 CCM Advanced,可以請 TAM 提供這項資訊。
    2. 在「Additional parameters」(其他參數) 欄位中,輸入執行個體的其他設定。這項設定可用來覆寫後端設定,例如語言、地理區域偵測和隱私權政策連結等。
  6. 啟用「Integrate CMP with Google Consent Mode」(整合 CMP 與 Google 同意聲明模式) 選項,完成「Google Consent Mode Integration」(Google 同意聲明模式整合) 設定。
  7. 根據您的設定,決定同意聲明類型和使用者偏好設定的對應關係。針對您要使用的每種同意聲明類型,對應到 Cookie 同意聲明值區 (「Required」、「Functional」、「Advertising」) 的相應 ID。在「Preferences Cookie」(偏好設定 Cookie) 欄位中,對應 cmapi_cookie_privacy 的第一方 Cookie。在「Behavior Cookie」(行為 Cookie) 欄位中,對應 notice_behavior 的第一方 Cookie。
  8. 依序按一下「觸發條件」>「Consent Initialization - All Pages」(同意聲明初始化 - 所有網頁) >「儲存」
  9. 按一下右上角的「預覽」測試容器 (請參閱下方的測試操作說明)。
  10. 發布容器。

使用其他平台或直接編輯網站程式碼

  1. 登入 TrustArc 支援入口網站,按下這個連結開啟「TrustArc Google Consent Mode Implementation Guide」(TrustArc Google 同意聲明模式導入指南),然後按照「Integrating the Consent Mode Using JavaScript」(使用 JavaScript 整合同意聲明模式) 一節的說明操作。
  2. 如果您使用網站製作工具,請參閱相關說明文件,瞭解如何在每個網頁的 head 代碼中導入程式碼。否則,請跳到步驟 3。
  3. 如果您使用「CCM Advanced」版本,請按照下列步驟操作。否則,請跳到步驟 4。在每個網頁的 head 代碼中 (如果使用網站製作工具,請參閱步驟 2),複製及貼上下方程式碼,然後將您在步驟 1 複製的 CMP 指令碼插入 head 代碼的最上方。請注意,這是確保 CMP 正常運作的必要動作。

    <script>

    window.dataLayer = window.dataLayer || [];

    function gtag(){dataLayer.push(arguments);}

     

    gtag('js', new Date());

    gtag('config', 'AW-YYYYYY');

     

    // Default consent types to 'denied' as a placeholder

    // Determine actual values based on your own requirements

    // Please omit consent types not being used

    gtag('consent', 'default', {

    'ad_storage': 'denied',

    'ad_user_data': 'denied',

    'ad_personalization': 'denied',

    'analytics_storage': 'denied',

    'functionality_storage': 'denied',

    'personalization_storage': 'denied',

    'security_storage': 'denied',

    'wait_for_update': 500

    });

    gtag('set', 'ads_data_redaction', true);

    gtag('set', 'developer_id.dNTIxZG', true);

    </script>

    <!--Banner script here!-->

  4. 如果您使用「CCM Pro」版本,請按照下列步驟操作。在每個網頁的 head 代碼中 (如果使用網站製作工具,請參閱步驟 2),複製及貼上下方程式碼,然後將您在步驟 1 複製的 CMP 指令碼插入 head 代碼的最上方。請注意,這是確保 CMP 正常運作的必要動作。請務必調整 CMP 值區與同意聲明類型之間的關聯。

    window.dataLayer = window.dataLayer || [];

    function gtag() { dataLayer.push(arguments); }

    gtag('js', new Date());

    gtag('config', 'GA_MEASUREMENT_ID');

    gtag('set', 'developer_id.dNTIxZG', true);

    // TODO: Can be changed according to customer's need and according to the configuration

    gtag('set', 'ads_data_redaction', true);

    gtag('set', 'url_passthrough', true);

    //Consent Mode Status

    const ConsentType = {

    DENIED: 'denied',

    GRANTED: 'granted',

    };

     

    const convertBooleanToGrantedOrDenied = (boolean) => boolean ? ConsentType.GRANTED : ConsentType.DENIED;

     

    /*

    TODO: This is where you can configure the Google Consent Mode, map the CMP categorisation and the default values for the consent initialization

    Google recommends commenting our consent types that you are not going to use.

    */

    const domain = 'your_domain.com'; // TODO: update

    // Bucket Mapping

    const REQUIRED = 1;

    const FUNCTIONAL = 2;

    const ADVERTISING = 3;

    const consentTypesMapped = {

    'ad_storage': ADVERTISING,

    'ad_user_data': ADVERTISING,

    'ad_personalization': FUNCTIONAL,

    'analytics_storage': FUNCTIONAL,

    'functionality_storage': FUNCTIONAL,

    'personalization_storage': FUNCTIONAL,

    'security_storage': REQUIRED

    }

    const getConsentState = (prefCookie) => {

    var consentStates = {};

    var noticeBehavior = window.truste.util.readCookie("notice_behavior");

    /*

    TODO: Can be changed according to customer's need and according to the configuration

    */

    var impliedLocation = noticeBehavior && noticeBehavior.includes("na");

    for (const consentType in consentTypesMapped) {

    var id = consentTypesMapped[consentType];

     

    if(prefCookie && !prefCookie.includes(0)) {

    console.log("Existing consent..");

    consentStates[consentType] = convertBooleanToGrantedOrDenied(prefCookie && prefCookie.includes(id));

    } else {

    console.log("Non Existing consent..");

    consentStates[consentType] = convertBooleanToGrantedOrDenied(impliedLocation);

    ;}

    ;}

    consentStates['wait_for_update'] = 500;

    console.log(consentStates);

    return consentStates;

    };

    /*

    Helper function to submit a GCM event based on user's preferences on TrustArc's Script

    consent: The consent object will be an array of values [1, 2, 3, n] as 1 being if the user consented to required, 2 to function, ... etc

    This function needs to be customized according to the customer's needed mapping. Ex: 'ad_storage': returnGrantedOrDenied(advertisingAccepted) is being mapped to advertising. if we were to map it to functional instead, we just need to change the bucket variable it's looking at. 

    */

     

    var runOnceGCM = 0;

    function handleConsentDecisionForGCM(consent) {

    //This code initializes the consent mode

    const consentStates = getConsentState(consent.consentDecision);

    var defaultOrUpdate;

    if (runOnceGCM == 0) {

    defaultOrUpdate = 'default';

    runOnceGCM++;

    } else {

    console.log('consent is being updated');

    defaultOrUpdate = 'update';

    }

    console.log(consentStates);

    //Once consent is changed, we will send an update 

    gtag('consent', defaultOrUpdate, {

    consentStates

    });

    }

     

    // This code is responsible for listening to any consent changes trough TrustArc's CCM Instance

    // And pushing the consent changes to the dataLayer according to the customer's consent mapping

    // This is for the intial load. If the user has a consent different from the default values, this is to push an update to the datalayer 

    // Once the CCM loads. 

    var interval = setInterval(() => {

    if (window.truste) {

    var consentDecision = truste.cma.callApi("getGDPRConsentDecision", domain);

    handleConsentDecisionForGCM(consentDecision);

    clearInterval(interval);

    console.log("running once...");

    }

    }, 100);

     

    // Start listening to when users submit their preferences  

    window.addEventListener("message", (event) => {

    let eventDataJson = null;

    // We only care about TrustArc Events at this point. And TrustArc's even it encoded in JSON

    try {

    eventDataJson = JSON.parse(event.data);

    } catch {

    // Some other event that is not JSON. 

    // TrustArc encodes the data as JSON

    // console.log(event.data);

    }

     

    // Safeguard to make sure we are only getting events from TrustArc

    if (eventDataJson && eventDataJson.source === "preference_manager") {

    // Means that the user has submited their preferences

    if (eventDataJson.message === "submit_preferences") {

    console.log("Event Data: ", eventDataJson);

    // Waiting half a second to make sure user's preferences are reflected. 

    setTimeout(() => {

    var consentDecision = truste.cma.callApi("getGDPRConsentDecision", domain);

    console.log("Consent Decision: ", consentDecision);

    handleConsentDecisionForGCM(consentDecision);

    }, 500);

    }

    }

    }, false);

    <!--Banner script here!-->

使用 Tag Assistant 進行測試

進一步瞭解如何使用 Google 代碼管理工具排解同意聲明模式的問題

這對您有幫助嗎?

我們應如何改進呢?
true
Achieve your advertising goals today!

Attend our Performance Max Masterclass, a livestream workshop session bringing together industry and Google ads PMax experts.

Register now

搜尋
清除搜尋內容
關閉搜尋
主選單
2424423231197267958
true
搜尋說明中心
true
true
true
true
true
73067
false
false
false