จะแสดงหรือบล็อกโฆษณา Adsense ที่ปรับเปลี่ยนตามความต้องการของ IAB TCF v2.0 ด้วย Quantcast Choice ได้อย่างไร

Aug 16 2020

ฉันได้เลือก Quantcast Choice เป็นแพลตฟอร์มการจัดการคำยินยอมสำหรับเว็บไซต์ของฉัน อย่างไรก็ตามด้วยโซลูชันพื้นฐานโฆษณา Google Adsense จะยังคงให้บริการแก่ผู้เยี่ยมชมก่อนที่จะให้ความยินยอมแก่ผู้ให้บริการที่เกี่ยวข้อง (Google) เนื่องจาก 2 วันมีการแจ้งเตือนใน Adsense เพื่อยืนยันปัญหานี้และหลังจากระยะเวลาผ่อนผัน 90 วันจะไม่มีการแสดงโฆษณาอีกต่อไป ข้อความแสดงข้อผิดพลาด: " 2.1a: แท็กหรือ SDK ไม่ได้รับสตริง TC เนื่องจากสถานะ CMP ถูกหยุดการโหลดหรือข้อผิดพลาด "

ฉันไม่คุ้นเคยกับสคริปต์เลย แต่ดูเหมือนว่าฉันต้องใช้บางสคริปต์เพื่อให้ Quantcast Choice ใช้งานได้จริง โดยพื้นฐานแล้วฉันต้องรู้วิธี:

  • ไม่แสดงโฆษณา Google ใด ๆ ก่อนที่ผู้เยี่ยมชมจะยินยอมให้ Google
  • แสดงโฆษณาที่ปรับให้เหมาะกับแต่ละบุคคลหลังจากได้รับความยินยอม
  • แสดงโฆษณาที่ไม่ได้ปรับให้เหมาะกับแต่ละบุคคลหลังจากไม่ได้รับความยินยอม

สิ่งที่ฉันได้เรียนรู้จนถึงตอนนี้:

ก่อนที่จะได้รับความยินยอมจากผู้เยี่ยมชมฉันสามารถเพิ่มสคริปต์นี้ในโค้ด Google Adsense เพื่อไม่ให้แสดงโฆษณาใด ๆ :

<script>(adsbygoogle=window.adsbygoogle||[]).pauseAdRequests=1;</script>

ไม่มีปัญหา อย่างไรก็ตามฉันควรจะสามารถทราบได้ว่าผู้เยี่ยมชมให้ความยินยอมสำหรับผู้ให้บริการ Google หรือไม่ รหัสผู้ให้บริการของ Google ใน TCF v2.0 คือ 755 ฉันพบส่วนผสมของโค้ดและข้อความต่อไปนี้ในหนึ่งในหน้า Quantcast แต่ฉันไม่รู้วิธีใช้ ฉันควรวางสิ่งนี้ไว้ในหน้าเว็บของฉันภายในสคริปต์ Quantcast Choice หรือ ... ? (ลิงก์แหล่งที่มาด้านล่าง)

{{QC - __cmpConsents.iabVendorConsentIds}} matches the regular expression (^|,)755(,|$).

ดังนั้นหากพบ ID 755 ฉันควรโทร:

(adsbygoogle=window.adsbygoogle||[]).pauseAdRequests=0

และหากไม่พบ ID 755 ฉันควรโทร:

(adsbygoogle=window.adsbygoogle||[]).requestNonPersonalizedAds=1
(adsbygoogle=window.adsbygoogle||[]).pauseAdRequests=0

แต่ฉันจะ "โทร" เหล่านี้ได้อย่างไร?

ดังนั้นฉันคิดว่าฉันเข้าใจขั้นตอนในการปฏิบัติตาม แต่ฉันไม่รู้วิธีใช้ขั้นตอนเหล่านี้และเชื่อมต่อจุดต่างๆ ความช่วยเหลือใด ๆ จะได้รับการชื่นชมมาก!

แหล่งที่ฉันใช้:

  • https://support.google.com/adsense/answer/9042142
  • https://help.quantcast.com/hc/en-us/articles/360051794434

ตัวอย่างเว็บไซต์ที่ดูเหมือนจะทำในสิ่งที่ต้องการ: carscoops.com

คำตอบ

3 quick Sep 18 2020 at 07:52

ฉันอยากจะแนะนำวิธีง่ายๆ ด้วย TCF 2.0 คุณไม่จำเป็นต้องกำหนดค่าพารามิเตอร์ Adsense ด้วยตนเอง (โฆษณาที่ปรับให้เหมาะกับแต่ละบุคคลเป็นต้น) ตามความยินยอมที่กำหนด คุณต้องรับประกันว่าคุณจะเริ่มโหลดโฆษณาหลังจากโหลดคำยินยอมสำเร็จแล้ว ไลบรารี Adsense อ่านสตริงคำยินยอมโดยอัตโนมัติและแสดงโฆษณาตามความยินยอมที่กำหนด

ตัวอย่างโค้ดสำหรับการรวม Quantcast Choices กับ Adsense:

<!-- Quantcast Choice. Consent Manager Tag v2.0 (for TCF 2.0) -->
...
<!-- End Quantcast Choice. Consent Manager Tag v2.0 (for TCF 2.0) -->

<script>
__tcfapi('addEventListener', 2, function(tcData, success) {
    if (success) {
        if (tcData.eventStatus == 'useractioncomplete' || tcData.eventStatus == 'tcloaded') {
            var hasStoreOnDeviceConsent = tcData.purpose.consents[1] || false;

            if (hasStoreOnDeviceConsent) {
                var adsbygoogle_script = document.createElement('script');
                adsbygoogle_script.src = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';
                document.head.appendChild(adsbygoogle_script);
            }
        }
    }
});
</script>
2 RyanBaron Aug 17 2020 at 17:04

เพื่อช่วยให้ทุกคนเข้าใจข้อผิดพลาด 2.1a Google IAB TCF v2น่าจะเกิดจากการเพิ่มแท็กผลิตภัณฑ์โฆษณาของ Google ลงในเว็บไซต์ก่อนที่จะมีการตั้งค่า / สร้างคำยินยอมจากผู้ใช้ นี่เป็นวิดีโอสั้น ๆ ที่แสดงให้เห็นถึงพฤติกรรมที่คาดหวังโฆษณาจะไม่โหลดจนกว่าจะได้รับคำยินยอมจากผู้ใช้ หากคุณเห็นโฆษณาโหลดอยู่เบื้องหลังก่อนที่ผู้ใช้จะเลือกคำยินยอมแสดงว่าคุณได้รับข้อผิดพลาด 2.1a เนื่องจากคุณเพิ่มแท็ก Google โดยไม่ต้องรอคำยินยอม

วิธีแก้ปัญหานี้จะแตกต่างกันไปขึ้นอยู่กับว่าคุณเพิ่มแท็กผลิตภัณฑ์โฆษณา Google ลงในไซต์ของคุณอย่างไร แต่หวังว่าข้อมูลด้านล่างและตัวอย่าง Adsense จะช่วยได้

Google Tag Manager

หากคุณใช้ Google Tag Manager เพื่อเพิ่มตัวเลือกและแท็ก Google ในไซต์ของคุณคุณสามารถใช้คำแนะนำได้ที่นี่ https://help.quantcast.com/hc/en-us/articles/360051794434 และ https://help.quantcast.com/hc/en-us/articles/360051794434-TCF-v2-GTM-Implementation-Guide-IAB-Vendor-Tag-Blocking เป็นข้อมูลอ้างอิง

ตัวอย่างเฉพาะของ Adsense

นำตัวอย่างจาก https://support.google.com/adsense/answer/9042142 ฉันเชื่อว่านี่เป็นวิธีที่คุณจะต้องปรับปรุงตัวอย่างใหม่เพื่อรอสัญญาณยินยอมที่เหมาะสมจาก Quantcast Choice TCF v2.0

ฉันไม่ได้มีโอกาสทดสอบอย่างเต็มที่ดังนั้นโปรดแจ้งให้เราทราบหากคุณมีปัญหาเกี่ยวกับรหัสและฉันจะอัปเดตตัวอย่าง

ดูบล็อกรหัสนี้ด้านล่างสำหรับเวอร์ชันที่อัปเดต

<html>
  <head>
    <title>Your site title</title>
  </head>
  <body>

    <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <script>
      // Initially pause adsbygoogle (wait for consent to unpause)
      (adsbygoogle=window.adsbygoogle||[]).pauseAdRequests=1;
    </script>

    <script>
      ( function() {
        // Run this in an interval (every 0.1s) just in case we are still waiting for consent
        var cnt = 0;
        var consentSetInterval = setInterval(function(){
          cnt += 1;

          // Bail if we have not gotten a consent response after 60 seconds.
          if( cnt === 600 )
            clearInterval(consentSetInterval);

          if( typeof window.__tcfapi !== 'undefined' ) { // Check if window.__tcfapi has been set
            clearInterval( consentSetInterval );

            window.__tcfapi( 'addEventListener', 2, function( tcData,listenerSuccess ) {
              if ( listenerSuccess ) {
                if( tcData.eventStatus === 'tcloaded' || tcData.eventStatus === 'useractioncomplete' ) {
                  if ( ! tcData.gdprApplies ) {

                    // GDPR DOES NOT APPLY, UnpauseAdRequests

                    // Set request non-personalized ads to false as GDPR does not apply.
                    (adsbygoogle=window.adsbygoogle||[]).requestNonPersonalizedAds=0;

                    // Unpause ads, as GDPR does not apply.
                    (adsbygoogle = window.adsbygoogle || []).pauseAdRequests=0;

                  }
                  else {

                    // GDPR DOES APPLY

                    // Purpose 1 refers to the storage and/or access of information on a device.
                    var hasDeviceStorageAndAccessConsent = tcData.purpose.consents[1] || false;

                    // Google Requires Consent for Purpose 1
                    if (hasDeviceStorageAndAccessConsent) {
                      // GLOBAL VENDOR LIST - https://iabeurope.eu/vendor-list-tcf-v2-0/
                      // CHECK FOR GOOGLE ADVERTISING PRODUCTS CONSENT. (IAB Vendor ID 755)
                      var hasGoogleAdvertisingProductsConsent = tcData.vendor.consents[755] || false;

                      // Check if the user gave Google Advertising Products consent (iab vendor 755)
                      if(hasGoogleAdvertisingProductsConsent) {
                        var hasPersonalizedProfileConsent = tcData.purpose.consents[3] || false;
                        var hasPersonalizedAdsConsent = tcData.purpose.consents[4] || false;

                        // Check if have add personalization consent Purpose 3 and 4
                        if( hasPersonalizedAdsConsent && hasPersonalizedProfileConsent ) {
                          // Set request non-personalized ads to false.
                          (adsbygoogle=window.adsbygoogle||[]).requestNonPersonalizedAds=0;
                        }
                        else {
                          // Set request non-personalized ads to true.
                          (adsbygoogle=window.adsbygoogle||[]).requestNonPersonalizedAds=1;
                        }

                        // Unpause ads , the user has granted consent for purpose 1 and given google consent.
                        (adsbygoogle = window.adsbygoogle || []).pauseAdRequests=0;
                      }
                    }
                  }
                }
              }
            } );
          }
          cnt++;
        }, 100);
      })();
    </script>

    <!-- One test unit for GDPR -->
    <ins class="adsbygoogle"
         style="display:inline-block;width:970px;height:250px"
         data-ad-client="ca-pubxxx"
         data-ad-slot="slot_id">
    </ins>

    <!-- Another test unit for GDPR -->
    <ins class="adsbygoogle"
         style="display:inline-block;width:250px;height:250px"
         data-ad-client="ca-pubxxx"
         data-ad-slot="slot_id">
    </ins>

    <script>
      // This will trigger the ad request if ads were unpaused in the CMP consent check above.
      (adsbygoogle = window.adsbygoogle || []).push({});
    </script>

  </body>
</html>

แก้ไข: เพิ่มเวอร์ชันอัปเดตใหม่ (18 ส.ค. )


นี่อาจเป็นเวอร์ชันที่ดีกว่าข้างต้น นี่เป็นการทดสอบอีกครั้งดังนั้นโปรดทดสอบและให้ข้อเสนอแนะหากคุณประสบปัญหา ความแตกต่างหลักของเวอร์ชันที่อัปเดตนี้คือ:
  1. เราไม่ได้ตรวจสอบ tcData.purpose.consents [3] และ tcData.purpose.consents [4] อีกต่อไป แต่เราอาศัย Google ในการตัดสินใจว่าจะแสดงโฆษณาที่ปรับตามโปรไฟล์ของผู้ใช้หรือไม่

  2. เราไม่ได้เพิ่ม https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.jsไปยังเพจจนกว่าเราจะได้รับความยินยอมป้องกันไม่ให้มีการเพิ่มคุกกี้ที่ไม่ต้องการจนกว่าเราจะแน่ใจว่าได้รับความยินยอม นอกจากนี้ยังทำให้เราสามารถลบ (adsbygoogle = window.adsbygoogle || []). pauseAdRequests = 1; รายการเช่นกัน

  <html>
    <head>
      <title>Your site title</title>
    </head>
    <body>
      <script>
        ( function() {
          var insertAdsByGoogleJs = function() {
            var element = document.createElement('script');
            var firstScript = document.getElementsByTagName('script')[0];
            var url = "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js";
            element.async = true;
            element.type = 'text/javascript';
            element.src = url;
            firstScript.parentNode.insertBefore(element, firstScript);
          };
          // Run this in an interval (every 0.1s) just in case we are still waiting for consent
          var cnt = 0;
          var consentSetInterval = setInterval(function(){
            cnt += 1;
            // Bail if we have not gotten a consent response after 60 seconds.
            if( cnt === 600 )
              clearInterval(consentSetInterval);
            if( typeof window.__tcfapi !== 'undefined' ) { // Check if window.__tcfapi has been set
              clearInterval( consentSetInterval );
              window.__tcfapi( 'addEventListener', 2, function( tcData,listenerSuccess ) {
                if ( listenerSuccess ) {
                  if( tcData.eventStatus === 'tcloaded' || tcData.eventStatus === 'useractioncomplete' ) {
                    if ( ! tcData.gdprApplies ) {
                      // GDPR DOES NOT APPLY
                      // Insert adsbygoogle.js onto the page.
                      insertAdsByGoogleJs();
                    }
                    else {
                      // GDPR DOES APPLY
                      // Purpose 1 refers to the storage and/or access of information on a device.
                      var hasDeviceStorageAndAccessConsent = tcData.purpose.consents[1] || false;
                      // Google Requires Consent for Purpose 1
                      if (hasDeviceStorageAndAccessConsent) {
                        // GLOBAL VENDOR LIST - https://iabeurope.eu/vendor-list-tcf-v2-0/
                        // CHECK FOR GOOGLE ADVERTISING PRODUCTS CONSENT. (IAB Vendor ID 755)
                        var hasGoogleAdvertisingProductsConsent = tcData.vendor.consents[755] || false;
                        // Check if the user gave Google Advertising Products consent (iab vendor 755)
                        if(hasGoogleAdvertisingProductsConsent) {
                          // Insert adsbygoogle.js onto the page.
                          insertAdsByGoogleJs();
                        }
                      }
                    }
                  }
                }
              } );
            }
            cnt++;
          }, 100);
        })();
      </script>
      <!-- One test unit for GDPR -->
      <ins class="adsbygoogle"
           style="display:inline-block;width:970px;height:250px"
           data-ad-client="ca-pubxxx"
           data-ad-slot="slot_id">
      </ins>
      <!-- Another test unit for GDPR -->
      <ins class="adsbygoogle"
           style="display:inline-block;width:250px;height:250px"
           data-ad-client="ca-pubxxx"
           data-ad-slot="slot_id">
      </ins>
      <script>
        // This will trigger the ad request if ads were unpaused in the CMP consent check above.
        (adsbygoogle = window.adsbygoogle || []).push({});
      </script>
    </body>
  </html>