讓網(wǎng)站符合GDPR規(guī)范,WordPress網(wǎng)站安裝cookieYes的操作步驟
隨著歐洲GDPR《通用數(shù)據(jù)保護(hù)條例》的逼近,Google廣告要求網(wǎng)站需設(shè)置征求用戶同意使用Cookie的橫幅,本文針對(duì)WordPress建站來說一下安裝Consent Banner的步驟。
什么是 GDPR?
《歐盟一般數(shù)據(jù)保護(hù)條例》GDPR 是由歐盟委員會(huì)在2016年批準(zhǔn)的歐洲隱私法,旨在統(tǒng)一和規(guī)范歐盟居民對(duì)其個(gè)人數(shù)據(jù)的控制,該條例自 2018年 5月 25日生效。
GDPR這對(duì)每個(gè)人來說意味什么呢?
如果你是網(wǎng)站所有者并通過網(wǎng)絡(luò)表單收集個(gè)人數(shù)據(jù),尤其是來自居住在歐盟的人的個(gè)人數(shù)據(jù),則你需要使你的網(wǎng)站符合此法規(guī),更新網(wǎng)站的隱私政策以涵蓋通過網(wǎng)站收集的所有個(gè)人信息。
首先確認(rèn)網(wǎng)站框架是使用Wordpress搭建,我們使用WordPress的插件(CookieYes)來實(shí)現(xiàn)這一功能。
WP網(wǎng)站安裝cookieYes的操作步驟
1,進(jìn)入網(wǎng)站后臺(tái)找到【插件】-【安裝插件】
2,找到CookieYes插件 【安裝插件】-安裝好點(diǎn)擊【啟用】
3,這是我們?cè)谧髠?cè)欄會(huì)看到有【CookieYes】了點(diǎn)擊進(jìn)入 點(diǎn)擊【Connect Web App】
4,選擇Free 點(diǎn)擊【Connect for Free】
5,Sign up 注冊(cè) 填寫郵箱和密碼點(diǎn)擊注冊(cè)按鈕,記住密碼,注冊(cè)完成之后使用郵箱和密碼登陸
6,登陸后【Go to Web App】
點(diǎn)擊【Advanced Settings】-【Get installation code】
7,獲取代碼,復(fù)制代碼
8,將復(fù)制代碼放入到第三方代碼的頂部位置,如果使用wordpress自建站,對(duì)應(yīng)找到放置第三方代碼的位置放入<head>部分即可。
9,再將以下代碼復(fù)制同樣放入頂部代碼
<script> function getCookie(cookieName) { let cookie = {}; document.cookie.split(“;”).forEach(function (el) { let [key, value] = el.split(“=”); cookie[key.trim()] = value; }); return cookie[cookieName]; } window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } var json_consent_status; var cookievalue = JSON.stringify(getCookie(“consentstatus”))?.split(‘\\”‘); //默認(rèn)意見 if (cookievalue == undefined) { gtag(“consent”, “default”, { ‘ad_storage’: ‘denied’, ‘ad_user_data’: ‘denied’, ‘ad_personalization’: ‘denied’, ‘analytics_storage’: ‘denied’, ‘wait_for_update’: 500, region: [ ‘AT’, ‘BE’, ‘BG’, ‘CY’, ‘CZ’, ‘DE’, ‘DK’, ‘EE’, ‘ES’, ‘FI’, ‘FR’, ‘GR’, ‘HR’, ‘HU’, ‘IE’, ‘IS’, ‘IT’, ‘LI’, ‘LT’, ‘LU’, ‘LV’, ‘MT’, ‘NL’, ‘NO’, ‘PL’, ‘PT’, ‘RO’, ‘SE’, ‘SI’, ‘SK’ ], // apply default to specific regions only }); } //過往意見 if (cookievalue != undefined) { if ((cookievalue == ‘”granted”‘)) { gtag(“consent”, “default”, { ‘ad_storage’: ‘granted’, ‘ad_user_data’: ‘granted’, ‘ad_personalization’: ‘granted’, ‘analytics_storage’: ‘granted’, ‘wait_for_update’: 500, }); } else { gtag(“consent”, “default”, { ‘ad_storage’: ‘denied’, ‘ad_user_data’: ‘denied’, ‘ad_personalization’: ‘denied’, ‘analytics_storage’: ‘denied’, ‘wait_for_update’: 500, }); } } function setCookies(json_consent_status) { var currentDate = new Date(); var expirationDate = new Date(currentDate); expirationDate.setFullYear(currentDate.getFullYear() + 1); var expires = expirationDate.toUTCString(); document.cookie = “consentstatus=” + json_consent_status + “;expires=” + expires + “;path=/”; } //客戶點(diǎn)擊拒絕 document.addEventListener(‘click’, function (e) { const dom = e.target.closest(‘.cky-btn-reject’); if (dom === null) return; json_consent_status = ‘denied’; setCookies(json_consent_status); gtag(‘consent’, ‘update’, { ‘ad_storage’: ‘denied’, ‘ad_user_data’: ‘denied’, ‘ad_personalization’: ‘denied’, ‘analytics_storage’: ‘denied’ }); }); //客戶點(diǎn)擊授權(quán) document.addEventListener(‘click’, function (e) { const dom = e.target.closest(‘.cky-btn-accept’); if (dom === null) return; json_consent_status = ‘granted’; setCookies(json_consent_status); gtag(‘consent’, ‘update’, { ‘ad_storage’: ‘granted’, ‘ad_user_data’: ‘granted’, ‘ad_personalization’: ‘granted’, ‘analytics_storage’: ‘granted’ }); }); </script>
10,網(wǎng)站前臺(tái)刷新,顯示正確即安裝成功,去GA后臺(tái)測試吧~