<!-- CSS Styles - Add to your head tag or CSS file -->
<style>
.cookie-consent-banner {
position: fixed;
bottom: 20px;
left: 20px;
width: 420px;
max-width: 90%;
background-color: #fff;
padding: 18px;
border-radius: 12px;
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 5px 10px rgba(0, 0, 0, 0.05);
z-index: 1000;
display: flex;
flex-direction: column;
opacity: 0;
visibility: hidden;
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
}
.cookie-consent-banner.cookie-banner-show {
opacity: 1;
visibility: visible;
}
.cookie-consent-content {
display: flex;
flex-direction: column;
gap: 15px;
}
.cookie-consent-text {
text-align: left;
}
.cookie-consent-title {
font-size: 1.1rem;
font-weight: 600;
margin-bottom: 8px;
color: #4361ee;
}
.cookie-consent-description {
font-size: 0.85rem;
color: #666;
margin-bottom: 8px;
line-height: 1.4;
}
.cookie-consent-links {
display: flex;
justify-content: flex-start;
gap: 15px;
margin-top: 5px;
font-size: 0.8rem;
}
.cookie-consent-links a {
color: #4361ee;
text-decoration: none;
transition: all 0.3s ease;
}
.cookie-consent-links a:hover {
text-decoration: underline;
}
.cookie-consent-actions {
display: flex;
justify-content: flex-start;
gap: 10px;
flex-wrap: wrap;
}
.cookie-consent-btn {
padding: 10px 18px !important;
border: none !important;
border-radius: 8px !important;
cursor: pointer !important;
font-weight: 600 !important;
transition: all 0.3s ease !important;
font-size: 0.8rem !important;
white-space: nowrap !important;
letter-spacing: 0.2px !important;
font-family: inherit !important;
text-transform: none !important;
line-height: 1.4 !important;
margin: 0 !important;
text-decoration: none !important;
display: inline-block !important;
outline: none !important;
}
.cookie-consent-btn-primary {
background-color: #4361ee !important;
color: #fff !important;
box-shadow: 0 4px 12px rgba(67, 97, 238, 0.3), 0 1px 3px rgba(0, 0, 0, 0.08) !important;
transform: scale(1.05) !important;
}
.cookie-consent-btn-primary:hover {
background-color: #3f37c9 !important;
transform: translateY(-2px) scale(1.05) !important;
box-shadow: 0 6px 15px rgba(67, 97, 238, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}
.cookie-consent-btn-secondary {
background-color: #e9ecef !important;
color: #495057 !important;
}
.cookie-consent-btn-secondary:hover {
background-color: #dee2e6 !important;
}
@media (max-width: 480px) {
.cookie-consent-banner {
bottom: 10px;
left: 10px;
right:10px;
width: 100% !important;
width: 100% !important;
padding: 15px !important;
}
.cookie-consent-links {
flex-direction: column;
align-items: flex-start;
gap: 5px;
}
}
</style>
<!-- HTML - Add this wherever you want the banner to appear -->
<div class="cookie-consent-banner">
<div class="cookie-consent-content">
<div class="cookie-consent-text">
<div class="cookie-consent-title">
<span>We value your privacy</span>
</div>
<p class="cookie-consent-description">We use cookies to analyze our traffic and understand how you interact with our website. By clicking "Accept", you consent to our use of cookies to enhance your browsing experience.</p>
<div class="cookie-consent-links">
<a href="/privacy-policy">Privacy Policy</a>
<a href="/cookie-policy">Cookie Policy</a>
<a href="/terms-of-service">Terms of Service</a>
</div>
</div>
<div class="cookie-consent-actions">
<button class="cookie-consent-btn cookie-consent-btn-primary" id="cookie-accept-all">Accept</button>
<button class="cookie-consent-btn cookie-consent-btn-secondary" id="cookie-reject-all">Reject</button>
</div>
</div>
</div>
<!-- JavaScript - Add this before the closing body tag -->
<script>
(function() {
// Tracker blocker functionality (začíná zde)
const blockedDomains = [
'google-analytics.com',
'googletagmanager.com',
'hotjar.com',
'intercom.io',
'static.hotjar.com',
'script.hotjar.com',
'connect.facebook.net',
'analytics',
'gtag'
];
// Funkce pro kontrolu, zda uživatel udělil souhlas
function hasAnalyticsConsent() {
const storedConsent = getCookie('cookie_consent');
if (!storedConsent) return false;
try {
const preferences = JSON.parse(storedConsent);
return preferences.analytics === true;
} catch (e) {
return false;
}
}
// Blokace načítání skriptů pomocí override appendChild
const originalAppendChild = Node.prototype.appendChild;
Node.prototype.appendChild = function(node) {
if (node.nodeName === 'SCRIPT') {
const shouldBlock = blockedDomains.some(domain => {
return node.src && node.src.indexOf(domain) !== -1;
});
if (!hasAnalyticsConsent() && shouldBlock) {
console.log('Blocked tracker:', node.src);
return document.createComment('Tracker blocked: ' + node.src);
}
}
return originalAppendChild.call(this, node);
};
// Také override metody insertBefore pro úplnost
const originalInsertBefore = Node.prototype.insertBefore;
Node.prototype.insertBefore = function(node, nextSibling) {
if (node.nodeName === 'SCRIPT') {
const shouldBlock = blockedDomains.some(domain => {
return node.src && node.src.indexOf(domain) !== -1;
});
if (!hasAnalyticsConsent() && shouldBlock) {
console.log('Blocked tracker:', node.src);
return document.createComment('Tracker blocked: ' + node.src);
}
}
return originalInsertBefore.call(this, node, nextSibling);
};
// Blokace globálních funkcí, které by mohly trackery používat
if (typeof window.gtag === 'function') {
const originalGtag = window.gtag;
window.gtag = function() {
if (hasAnalyticsConsent()) {
return originalGtag.apply(this, arguments);
}
console.log('Blocked gtag call');
return null;
};
}
// Blokace dataLayer
if (window.dataLayer && Array.isArray(window.dataLayer)) {
const originalPush = window.dataLayer.push;
window.dataLayer.push = function() {
if (hasAnalyticsConsent()) {
return originalPush.apply(this, arguments);
}
console.log('Blocked dataLayer push');
return null;
};
}
// Blokace Hotjar
if (window.hj) {
const originalHj = window.hj;
window.hj = function() {
if (hasAnalyticsConsent()) {
return originalHj.apply(this, arguments);
}
console.log('Blocked Hotjar call');
return null;
};
}
// Blokace Intercom
if (window.Intercom) {
const originalIntercom = window.Intercom;
window.Intercom = function() {
if (hasAnalyticsConsent()) {
return originalIntercom.apply(this, arguments);
}
console.log('Blocked Intercom call');
return null;
};
}
// Tracker blocker functionality (končí zde)
// Cookie functionality
const cookieBanner = document.querySelector('.cookie-consent-banner');
const acceptAllBtn = document.getElementById('cookie-accept-all');
const rejectAllBtn = document.getElementById('cookie-reject-all');
// Check if consent has been given before
const hasConsent = getCookie('cookie_consent');
if (!hasConsent) {
// Show the cookie banner
cookieBanner.classList.add('cookie-banner-show');
}
// Accept analytics cookies
acceptAllBtn.addEventListener('click', function() {
setConsent({
necessary: true,
analytics: true
});
hideBanner();
// Enable analytics tracking
enableAnalytics();
// Reload the page to allow tracked scripts to load properly
setTimeout(function() {
window.location.reload();
}, 500);
});
// Reject analytics cookies
rejectAllBtn.addEventListener('click', function() {
setConsent({
necessary: true, // Necessary cookies are always accepted
analytics: false
});
hideBanner();
// Disable analytics tracking
disableAnalytics();
});
// Helper functions
function setConsent(preferences) {
// Convert the preferences object to a JSON string and store it in a cookie
setCookie('cookie_consent', JSON.stringify(preferences), 180); // Expires in 180 days
// You could also store these preferences in localStorage for easier access
localStorage.setItem('cookie_preferences', JSON.stringify(preferences));
}
function hideBanner() {
cookieBanner.classList.remove('cookie-banner-show');
}
function setCookie(name, value, days) {
const date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
const expires = "expires=" + date.toUTCString();
document.cookie = name + "=" + value + ";" + expires + ";path=/";
}
function getCookie(name) {
const cookieName = name + "=";
const cookies = document.cookie.split(';');
for (let i = 0; i < cookies.length; i++) {
let cookie = cookies[i].trim();
if (cookie.indexOf(cookieName) === 0) {
return cookie.substring(cookieName.length, cookie.length);
}
}
return null;
}
// Functions to handle analytics tracking
function enableAnalytics() {
console.log('Analytics tracking enabled');
(function(h,o,t,j,a,r){
h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};
h._hjSettings={hjid:5354998,hjsv:6};
a=o.getElementsByTagName('head')[0];
r=o.createElement('script');r.async=1;
r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;
a.appendChild(r);
})(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');
// Here you would initialize your analytics scripts
// For example:
// - Initialize Google Analytics
// - Initialize Matomo/Piwik
// - Initialize any other analytics tools
}
function disableAnalytics() {
console.log('Analytics tracking disabled');
// Clear existing analytics cookies
const cookiesToClear = [
'_ga', '_gid', '_gat', // Google Analytics
'hjClosedSurveyInvites', 'hjid', 'hjTLDTest', '_hjSession', // Hotjar
'intercom-id', 'intercom-session' // Intercom
];
cookiesToClear.forEach(cookieName => {
document.cookie = `${cookieName}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
document.cookie = `${cookieName}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=.${location.hostname};`;
});
}
// If there's already a consent stored, apply those preferences
if (hasConsent) {
try {
const preferences = JSON.parse(hasConsent);
if (preferences.analytics) {
enableAnalytics();
} else {
disableAnalytics();
}
} catch (e) {
console.error('Error parsing stored consent:', e);
}
}
})();
</script>