如果您想向位於歐洲經濟區或英國境內所有造訪您網站的使用者放送非個人化廣告,且已符合我們的《同意聲明政策》規定,則不必修改廣告代碼。只要到 AdSense 或 Google Ad Manager UI 中,啟用非個人化廣告放送功能即可。
不過,若您有特別需求 (例如想向某些使用者放送個人化廣告,對其他人則放送非個人化廣告),不妨參考以下範例。
請注意,下列程式碼範例無法在實作時使用,僅供您在導入廣告個人化設定時做為參考。
非個人化廣告的廣告程式碼
如果您想在某幾個網頁上放送非個人化廣告,請參考以下範例:
<html>
<head>
<title>Your site title</title>
</head>
<body>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pubxxx" crossorigin="anonymous"></script>
<script>(adsbygoogle=window.adsbygoogle||[]).requestNonPersonalizedAds=1;</script>
// The line above makes sure you are requesting non-personalized ads. It needs to come before you use <script>(adsbygoogle = window.adsbygoogle || []).push({});</script> and it suffices to have one such line per page.
<!-- 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>(adsbygoogle = window.adsbygoogle || []).push({});</script>
// This triggers the ad request.
</body>
</html>
<head>
<title>Your site title</title>
</head>
<body>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pubxxx" crossorigin="anonymous"></script>
<script>(adsbygoogle=window.adsbygoogle||[]).requestNonPersonalizedAds=1;</script>
// The line above makes sure you are requesting non-personalized ads. It needs to come before you use <script>(adsbygoogle = window.adsbygoogle || []).push({});</script> and it suffices to have one such line per page.
<!-- 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>(adsbygoogle = window.adsbygoogle || []).push({});</script>
// This triggers the ad request.
</body>
</html>
個人化廣告的廣告程式碼
如果您想向某些使用者放送個人化廣告,對其他人則放送非個人化廣告,請參考以下範例:
<html>
<head>
<title>Your site title</title>
</head>
<body>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pubxxx" crossorigin="anonymous"></script>
<script>(adsbygoogle=window.adsbygoogle||[]).pauseAdRequests=1;</script>
// This will pause ad requests, so users have time to interact with your consent solution.
/* Set up the consent solution and act according to the user choice.
If the user declines personalized ads, make sure to call (adsbygoogle=window.adsbygoogle||[]).requestNonPersonalizedAds=1;
Remember that you need user consent for using cookies even for non-personalized ads in countries where the EU eprivacy directive requires it.
Later, you can call (adsbygoogle=window.adsbygoogle||[]).pauseAdRequests=0 to resume sending ad requests. Without making this call, no ads will be shown.
*/
<!-- 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>(adsbygoogle = window.adsbygoogle || []).push({});</script>
// This usually triggers the ad request, but you have paused these.
</body>
</html>
<head>
<title>Your site title</title>
</head>
<body>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pubxxx" crossorigin="anonymous"></script>
<script>(adsbygoogle=window.adsbygoogle||[]).pauseAdRequests=1;</script>
// This will pause ad requests, so users have time to interact with your consent solution.
/* Set up the consent solution and act according to the user choice.
If the user declines personalized ads, make sure to call (adsbygoogle=window.adsbygoogle||[]).requestNonPersonalizedAds=1;
Remember that you need user consent for using cookies even for non-personalized ads in countries where the EU eprivacy directive requires it.
Later, you can call (adsbygoogle=window.adsbygoogle||[]).pauseAdRequests=0 to resume sending ad requests. Without making this call, no ads will be shown.
*/
<!-- 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>(adsbygoogle = window.adsbygoogle || []).push({});</script>
// This usually triggers the ad request, but you have paused these.
</body>
</html>
自動廣告:非個人化廣告的廣告程式碼
如果您想在某幾個網頁上放送非個人化自動廣告,請參考以下範例:
<html>
<head>
<title>Your site title</title>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pubxxx" crossorigin="anonymous"></script>
<script>
(adsbygoogle=window.adsbygoogle||[]).requestNonPersonalizedAds=1;
(adsbygoogle=window.adsbygoogle||[]).push({google_ad_client: "ca-pubxxx", enable_page_level_ads: true});
</script>
</head>
<body>
</body>
</html>
<head>
<title>Your site title</title>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pubxxx" crossorigin="anonymous"></script>
<script>
(adsbygoogle=window.adsbygoogle||[]).requestNonPersonalizedAds=1;
(adsbygoogle=window.adsbygoogle||[]).push({google_ad_client: "ca-pubxxx", enable_page_level_ads: true});
</script>
</head>
<body>
</body>
</html>
自動廣告:個人化廣告的廣告程式碼
如果您想向某些使用者放送個人化自動廣告,對其他人則放送非個人化自動廣告,請參考以下範例:
<html>
<head>
<title>Your site title</title>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pubxxx" crossorigin="anonymous"></script>
<script>
(adsbygoogle=window.adsbygoogle||[]).pauseAdRequests=1;
// This will pause ad requests, so users have time to interact with your consent solution.
(adsbygoogle=window.adsbygoogle||[]).push({google_ad_client: "ca-pubxxx", enable_page_level_ads: true});
// This usually triggers the ad request, but you have paused these.
</script>
</head>
<body>
<script>
/* Set up the consent solution and act according to the user choice.
If the user declines personalized ads, make sure to call (adsbygoogle=window.adsbygoogle||[]).requestNonPersonalizedAds=1;
Remember that you need user consent for using cookies even for non-personalized ads in countries where the EU eprivacy directive requires it.
Later, you can call (adsbygoogle=window.adsbygoogle||[]).pauseAdRequests=0 to resume sending ad requests. Without making this call, no ads will be shown.
*/
</script>
</body>
</html>
<head>
<title>Your site title</title>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pubxxx" crossorigin="anonymous"></script>
<script>
(adsbygoogle=window.adsbygoogle||[]).pauseAdRequests=1;
// This will pause ad requests, so users have time to interact with your consent solution.
(adsbygoogle=window.adsbygoogle||[]).push({google_ad_client: "ca-pubxxx", enable_page_level_ads: true});
// This usually triggers the ad request, but you have paused these.
</script>
</head>
<body>
<script>
/* Set up the consent solution and act according to the user choice.
If the user declines personalized ads, make sure to call (adsbygoogle=window.adsbygoogle||[]).requestNonPersonalizedAds=1;
Remember that you need user consent for using cookies even for non-personalized ads in countries where the EU eprivacy directive requires it.
Later, you can call (adsbygoogle=window.adsbygoogle||[]).pauseAdRequests=0 to resume sending ad requests. Without making this call, no ads will be shown.
*/
</script>
</body>
</html>