İstatistikler toplama uyarısı
Web sitenizin ziyaretçilerini, istatistiklerin toplanması konusunda uyarabilir ve site sayfalarında Yandex Metrica sayaç kodunun yüklenmesi geciktirebilirsiniz.
Veri aktarımının ziyaretçi tarafından onaylanması halinde sayaç kodu olağan şekilde yüklenir. Ziyaretçi izni olmadan kod yüklenmeyecektir. Ziyaretçinin bir kere yaptığı seçim, gerektiğinde sitenin (alan adının) tüm sayfalarını ziyaretler için geçerli sayılabilir.
Uyarıyı etkinleştirmek ve sayaç kodunun yüklenmesini geciktirmek için site yöneticinize başvurun.
Uyarı örneği
Ziyaretçileri bilgilendirmek için herhangi bir metin kullanabilirsiniz. Aşağıdaki metin sadece bildirimdeki metnin nasıl gösterildiğine dair bir örnek olarak verilmiştir. Yandex bunun yasal gerekliliklere uygunluğundan sorumlu değildir. Metni yayınlamadan önce hukukçunuza danışmanızı öneririz.
Bu site ziyaretçi istatistiklerini ve ziyaretçi verilerini toplamaktadır.
[Web sitenizin Kullanıcı Sözleşmesi’ne veya sitenizin Gizlilik Politikası’na bağlantı]
Kod uygulama örneği
...
<head>
<meta charset="UTF-8">
<title>Sayfa başlığı</title>
<!--В примере используется стиль reset.css. Вы можете использовать свое решение.-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
<!--В примере используется библиотека js-cookie для работы с cookie. Вы можете использовать свое решение-->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.1.2/js.cookie.js"></script>
<style>
* {
box-sizing: border-box;
}
body {
width: 100%;
height: 100%;
}
.cookie-notification {
position: fixed;
background-color: rgba(0, 0, 0, .8);
bottom: 0;
width: 100%;
color: white;
padding: 15px;
}
.cookie-notification_hidden_yes {
display: none;
}
.cookie-notification__header {
margin-bottom: 10px;
font-size: 23px;
}
.cookie-notification__body {
margin-bottom: 10px;
}
</style>
</head>
<body>
Sayfa içeriği
<div class="cookie-notification cookie-notification_hidden_yes">
<div class="cookie-notification__header">İstatistik toplama uyarısı</div>
<div class="cookie-notification__body">
<p>Bu site ziyaretçi istatistiklerini ve ziyaretçi verilerini toplamaktadır.</p>
<p>[Web sitenizin Kullanıcı Sözleşmesi’ne veya sitenizin Gizlilik Politikası’na bağlantı]</p>
</div>
<div class="cookie-notification__buttons">
<button class="cookie-notification__button" id="yes">Kabul ediyorum</button>
</div>
</div>
<script type="text/javascript">
var messageElement = document.querySelector('.cookie-notification');
// Если нет cookies, то показываем плашку
if (!Cookies.get('agreement')) {
showMessage();
} else {
initCounter();
}
// Загружаем сам код счетчика сразу
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
(window, document,'script','https://mc.yandex.ru/metrika/tag.js', 'ym')
// Функция добавляет класс к DOM-элементу. Вы можете использовать библиотеку jQuery или другой фреймворк
function addClass (o, c) {
var re = new RegExp("(^|\\s)" + c + "(\\s|$)", "g");
if (!o || re.test(o.className)) {
return;
}
o.className = (o.className + " " + c).replace(/\s+/g, " ").replace(/(^ | $)/g, "");
}
// Функция удаляет класс из DOM-элемента. Вы можете использовать библиотеку jQuery или другой фреймворк
function removeClass (o, c) {
var re = new RegExp('(^|\\s)' + c + '(\\s|$)', 'g');
if (!o) {
return;
}
o.className = o.className.replace(re, '$1').replace(/\s+/g, ' ').replace(/(^ | $)/g, '');
}
// Функция, которая прячет предупреждение
function hideMessage () {
addClass(messageElement, 'cookie-notification_hidden_yes');
}
// Функция, которая показывает предупреждение
function showMessage () {
removeClass(messageElement, 'cookie-notification_hidden_yes');
}
function saveAnswer () {
// Прячем предупреждение
hideMessage();
// Ставим cookies
Cookies.set('agreement', '1');
}
function initCounter () {
ym(XXXX, 'init', {});
saveAnswer();
}
// Нажатие кнопки "Я согласен"
document.querySelector('#yes').addEventListener('click', function () {
initCounter();
});
</script>
</body>
...
...
<head>
<meta charset="UTF-8">
<title>Page title</title>
<!--This example uses the reset.css style. You can use your own approach.-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
<!--The example uses the js-cookie library for working with cookies. You can use your own approach-->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.1.2/js.cookie.js"></script>
<style>
* {
box-sizing: border-box;
}
body {
width: 100%;
height: 100%;
}
.cookie-notification {
position: fixed;
background-color: rgba(0, 0, 0, .8);
bottom: 0;
width: 100%;
color: white;
padding: 15px;
}
.cookie-notification_hidden_yes {
display: none;
}
.cookie-notification__header {
margin-bottom: 10px;
font-size: 23px;
}
.cookie-notification__body {
margin-bottom: 10px;
}
</style>
</head>
<body>
Site Content
<div class="cookie-notification cookie-notification_hidden_yes">
<div class="cookie-notification__header">Предупреждение о сборе статистики</div>
<div class="cookie-notification__body">
<p>This website collects session statistics and user data.</p>
<p>[Link to the User Agreement of your website or to the Privacy Policy of your website]</p>
</div>
<div class="cookie-notification__buttons">
<button class="cookie-notification__button" id="yes">I agree</button>
</div>
</div>
<script type="text/javascript">
var messageElement = document.querySelector('.cookie-notification');
// If there aren't any cookies, show a placeholder
if (!Cookies.get('agreement')) {
showMessage();
} else {
initCounter();
}
// Load the code snippet immediately
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
(window, document,'script','https://mc.yandex.ru/metrika/tag.js', 'ym')
// This function adds the class to the DOM element. You can use the jQuery library or another framework
function addClass (o, c) {
var re = new RegExp("(^|\\s)" + c + "(\\s|$)", "g");
if (!o || re.test(o.className)) {
return;
}
o.className = (o.className + " " + c).replace(/\s+/g, " ").replace(/(^ | $)/g, "");
}
// This function removes the class from the DOM element. You can use the jQuery library or another framework.
function removeClass (o, c) {
var re = new RegExp('(^|\\s)' + c + '(\\s|$)', 'g');
if (!o) {
return;
}
o.className = o.className.replace(re, '$1').replace(/\s+/g, ' ').replace(/(^ | $)/g, '');
}
// Function that hides the alert.
function hideMessage () {
addClass(messageElement, 'cookie-notification_hidden_yes');
}
// Function that shows the alert.
function showMessage () {
removeClass(messageElement, 'cookie-notification_hidden_yes');
}
function saveAnswer () {
// Hide the alert.
hideMessage();
// Set cookies.
Cookies.set('agreement', '1');
}
function initCounter () {
ym(XXXX, 'init', {});
saveAnswer();
}
// Clicked the "I agree" button.
document.querySelector('#yes').addEventListener('click', function () {
initCounter();
});
</script>
</body>
...
Burada:
XXXXXX
: Sayacınızın numarasıdır.