New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fer-cookie-bot

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fer-cookie-bot - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

js/fer-cookiebot.min.js

274

js/fer-cookiebot.js

@@ -5,11 +5,15 @@ /* VERIFY CONSENT https://tagassistant.google.com */

constructor(googleTagId, facebookPixelId, options = {}) {
constructor(googleTagId, facebookPixelId, options = {}) {
this.googleTagId = googleTagId;
this.facebookPixelId = facebookPixelId || null;
this.dialogId = 'consentDialog';
this.options = options;
this.translations = this.defineTranslations();
this.language = document.documentElement.lang || "en"; // Default to English
this.translatedOptions = this.translations[this.language] || this.translations["en"]; // Fallback to English
this.loadGTagScript().then(() => {
// Load translations first
this.translations = this.defineTranslations();
// Determine the language-specific translations
const defaultTranslationsForLanguage = this.translations[this.language] || this.translations["en"];
// Merge the language-specific translations with any provided options
// This ensures that any provided option overrides the corresponding default translation
this.translatedOptions = { ...defaultTranslationsForLanguage, ...options };
this.initDataLayer();

@@ -83,2 +87,5 @@ this.initializeConsentMode();

'analytics_storage': 'denied',
'functionality_storage': 'denied',
'personalization_storage': 'denied',
'security_storage': 'denied',
'wait_for_update': 500,

@@ -89,8 +96,17 @@ });

updateConsent(adStorage, adUserData, adPersonalization, analyticsStorage) {
updateConsent(adStorage, adUserData, adPersonalization, analyticsStorage, functionalityStorage, personalizationStorage, securityStorage) {
this.gtag('consent', 'update', {
/* Consent Type */
'ad_storage': adStorage ? 'granted' : 'denied',
'ad_user_data': adUserData ? 'granted' : 'denied',
'ad_personalization': adPersonalization ? 'granted' : 'denied',
/* STORAGE TYPE */
'analytics_storage': analyticsStorage ? 'granted' : 'denied',
'functionality_storage': functionalityStorage ? 'granted' : 'denied',
'personalization_storage': personalizationStorage ? 'granted' : 'denied',
'security_storage': securityStorage ? 'granted' : 'denied',
});

@@ -101,3 +117,6 @@ localStorage.setItem('consentSettings', JSON.stringify({

adPersonalization,
analyticsStorage
analyticsStorage,
functionalityStorage,
personalizationStorage,
securityStorage
}));

@@ -138,3 +157,16 @@ }

text: this.translatedOptions.analytics_storage_title
},
{
id: 'functionality_storage',
text: this.translatedOptions.functionality_storage_title
},
{
id: 'personalization_storage',
text: this.translatedOptions.personalization_storage_title
},
{
id: 'security_storage',
text: this.translatedOptions.security_storage_title
}
];

@@ -144,3 +176,2 @@ consentItems.forEach(item => {

label.className = 'consent-item';
const input = document.createElement('input');

@@ -151,8 +182,5 @@ input.type = 'checkbox';

if (item.checked) input.checked = true;
const textNode = document.createTextNode(' ' + item.text);
label.appendChild(input);
label.appendChild(textNode);
dialog.appendChild(label);

@@ -165,3 +193,16 @@ });

dialog.appendChild(consentTextDiv);
// Create and append the save preferences button
const acceptAllButton = document.createElement('button');
acceptAllButton.id = 'saveAcceptAllCookieBotPreferences';
acceptAllButton.className = 'consent-button';
acceptAllButton.innerText = this.translatedOptions.accept_all_button_title;
// Create and append the save preferences button
const refuseAllButton = document.createElement('button');
refuseAllButton.id = 'saveRefuseAllCookieBotPreferences';
refuseAllButton.className = 'consent-button';
refuseAllButton.innerText = this.translatedOptions.refuse_all_button_title;
// Create and append the save preferences button
const saveButton = document.createElement('button');

@@ -171,15 +212,24 @@ saveButton.id = 'saveCookieBotPreferences';

saveButton.innerText = this.translatedOptions.button_title;
dialog.appendChild(acceptAllButton);
dialog.appendChild(refuseAllButton);
dialog.appendChild(saveButton);
}
acceptAndSaveAll() {
this.updateConsent(true, true, true, true, true, true, true);
this.loadConsentSettings();
localStorage.setItem('dialogState', 'closed');
this.closeDialog();
}
refuseAndSaveAll() {
this.updateConsent(false, false, false, false, false, false, false);
this.loadConsentSettings();
localStorage.setItem('dialogState', 'closed');
this.closeDialog();
}
loadConsentSettings() {
const consentSettings = JSON.parse(localStorage.getItem('consentSettings'));
/* START BUTTON */
if (document.getElementById('changeCookieBotPreferences')) {
document.getElementById('changeCookieBotPreferences').addEventListener('click', () => {
this.openDialog();
});
}
if (consentSettings) {

@@ -190,4 +240,7 @@ document.getElementById('ad_storage').checked = consentSettings.adStorage;

document.getElementById('analytics_storage').checked = consentSettings.analyticsStorage;
document.getElementById('functionality_storage').checked = consentSettings.functionalityStorage;
document.getElementById('personalization_storage').checked = consentSettings.personalizationStorage;
document.getElementById('security_storage').checked = consentSettings.securityStorage;
}
if (consentSettings.adStorage == true && consentSettings.adUserData == true) {
if (consentSettings && (consentSettings.adStorage == true && consentSettings.adUserData == true)) {
this.addFacebookPixel();

@@ -218,2 +271,3 @@ }

attachEventListeners() {
const saveButton = document.getElementById('saveCookieBotPreferences');

@@ -225,13 +279,42 @@ if (saveButton) {

}
const acceptAllButton = document.getElementById('saveAcceptAllCookieBotPreferences');
if (acceptAllButton) {
acceptAllButton.addEventListener('click', () => {
this.acceptAndSaveAll();
})
}
const refuseAllButton = document.getElementById('saveRefuseAllCookieBotPreferences');
if (refuseAllButton) {
refuseAllButton.addEventListener('click', () => {
this.refuseAndSaveAll();
})
}
/* START BUTTON */
if (document.getElementById('changeCookieBotPreferences')) {
document.getElementById('changeCookieBotPreferences').addEventListener('click', () => {
this.openDialog();
});
}
}
saveCookieBotPreferences() {
const adStorage = document.getElementById('ad_storage').checked;
const adUserData = document.getElementById('ad_user_data').checked;
const adPersonalization = document.getElementById('ad_personalization').checked;
const analyticsStorage = document.getElementById('analytics_storage').checked;
this.updateConsent(adStorage, adUserData, adPersonalization, analyticsStorage);
const functionalityStorage = document.getElementById('functionality_storage').checked;
const personalizationStorage = document.getElementById('personalization_storage').checked;
const securityStorage = document.getElementById('security_storage').checked;
this.updateConsent(adStorage, adUserData, adPersonalization, analyticsStorage, functionalityStorage, personalizationStorage, securityStorage);
// Set dialog state as 'closed' in localStorage after saving preferences
localStorage.setItem('dialogState', 'closed');
this.closeDialog();
}

@@ -243,3 +326,3 @@

hr: {
title: "Vaš naslov pristanka",
title: "Privola za korištenje osobnih podataka",
necessary_cookies_title: "Nužni kolačići",

@@ -250,3 +333,8 @@ ad_storage_title: "Oglašavački kolačići",

analytics_storage_title: "Kolačići analitike",
button_title: "Spremi postavke",
functionality_storage_title: "Kolačići funkcionalnosti",
personalization_storage_title: "Kolačići personalizacije",
security_storage_title: "Kolačići sigurnosti",
button_title: "Spremi odabrano",
accept_all_button_title: "Prihvati sve",
refuse_all_button_title: "Odbaci sve",
consent_text: "Ova web-stranica koristi kolačiće. Kolačiće upotrebljavamo kako bismo personalizirali sadržaj i oglase, omogućili značajke društvenih medija i analizirali promet.",

@@ -256,3 +344,3 @@ consent_link: "<a href='https://policies.google.com/privacy' target='_blank'>Opširnije</a>",

en: {
title: "Your Consent Title",
title: "Consent for the Use of Personal Data",
necessary_cookies_title: "Necessary Cookies",

@@ -263,52 +351,77 @@ ad_storage_title: "Advertising Cookies",

analytics_storage_title: "Analytics Cookies",
button_title: "Save Settings",
consent_text: "This website uses cookies. We use cookies to personalize content and ads, provide social media features, and analyze our traffic.",
functionality_storage_title: "Functionality Cookies",
personalization_storage_title: "Personalization Cookies",
security_storage_title: "Security Cookies",
button_title: "Save Selected",
accept_all_button_title: "Accept All",
refuse_all_button_title: "Refuse All",
consent_text: "This website uses cookies. We use cookies to personalize content and ads, to provide social media features, and to analyze our traffic.",
consent_link: "<a href='https://policies.google.com/privacy' target='_blank'>Learn More</a>",
},
de: {
title: "Ihre Zustimmung",
title: "Zustimmung zur Verwendung persönlicher Daten",
necessary_cookies_title: "Notwendige Cookies",
ad_storage_title: "Werbungs-Cookies",
ad_storage_title: "Werbe-Cookies",
ad_user_data_title: "Nutzung von Werbedaten",
ad_personalization_title: "Personalisierung der Werbung",
analytics_storage_title: "Analyse-Cookies",
button_title: "Einstellungen speichern",
consent_text: "Diese Webseite verwendet Cookies. Wir verwenden Cookies, um Inhalte und Anzeigen zu personalisieren, Funktionen für soziale Medien anbieten zu können und den Verkehr zu analysieren.",
ad_personalization_title: "Anzeigenpersonalisierung",
analytics_storage_title: "Analytische Cookies",
functionality_storage_title: "Funktionalitäts-Cookies",
personalization_storage_title: "Personalisierungs-Cookies",
security_storage_title: "Sicherheits-Cookies",
button_title: "Ausgewähltes speichern",
accept_all_button_title: "Alles akzeptieren",
refuse_all_button_title: "Alles ablehnen",
consent_text: "Diese Webseite verwendet Cookies. Wir verwenden Cookies, um Inhalte und Anzeigen zu personalisieren, Funktionen für soziale Medien anzubieten und unseren Verkehr zu analysieren.",
consent_link: "<a href='https://policies.google.com/privacy' target='_blank'>Mehr erfahren</a>",
},
it: {
title: "Il tuo consenso",
title: "Consenso per l'uso dei dati personali",
necessary_cookies_title: "Cookie necessari",
ad_storage_title: "Cookie pubblicitari",
ad_user_data_title: "Utilizzo dei dati pubblicitari",
ad_user_data_title: "Uso dei dati pubblicitari",
ad_personalization_title: "Personalizzazione degli annunci",
analytics_storage_title: "Cookie analitici",
button_title: "Salva impostazioni",
consent_text: "Questo sito utilizza i cookie. Utilizziamo i cookie per personalizzare contenuti e annunci, fornire funzionalità dei social media e analizzare il nostro traffico.",
functionality_storage_title: "Cookie di funzionalità",
personalization_storage_title: "Cookie di personalizzazione",
security_storage_title: "Cookie di sicurezza",
button_title: "Salva selezionati",
accept_all_button_title: "Accetta tutto",
refuse_all_button_title: "Rifiuta tutto",
consent_text: "Questo sito utilizza i cookie. Utilizziamo i cookie per personalizzare contenuti e annunci, fornire funzioni dei social media e analizzare il nostro traffico.",
consent_link: "<a href='https://policies.google.com/privacy' target='_blank'>Scopri di più</a>",
},
ru: {
title: "Ваше согласие",
title: "Согласие на использование личных данных",
necessary_cookies_title: "Необходимые куки",
ad_storage_title: "Куки для рекламы",
ad_user_data_title: "Использование данных для рекламы",
ad_user_data_title: "Использование данных рекламы",
ad_personalization_title: "Персонализация рекламы",
analytics_storage_title: "Аналитические куки",
button_title: "Сохранить настройки",
consent_text: "Этот сайт использует куки. Мы используем куки для персонализации контента и рекламы, предоставления социальных медиа функций и анализа нашего трафика.",
functionality_storage_title: "Функциональные куки",
personalization_storage_title: "Куки персонализации",
security_storage_title: "Куки безопасности",
button_title: "Сохранить выбранное",
accept_all_button_title: "Принять все",
refuse_all_button_title: "Отклонить все",
consent_text: "Этот сайт использует куки. Мы используем куки для персонализации контента и рекламы, предоставления функций социальных сетей и анализа трафика.",
consent_link: "<a href='https://policies.google.com/privacy' target='_blank'>Узнать больше</a>",
},
pl: {
title: "Twoja zgoda",
title: "Zgoda na używanie danych osobowych",
necessary_cookies_title: "Niezbędne ciasteczka",
ad_storage_title: "Ciasteczka reklamowe",
ad_user_data_title: "Używanie danych reklamowych",
ad_user_data_title: "Użycie danych reklamowych",
ad_personalization_title: "Personalizacja reklam",
analytics_storage_title: "Ciasteczka analityczne",
button_title: "Zapisz ustawienia",
consent_text: "Ta strona używa ciasteczek. Używamy ciasteczek do personalizacji treści i reklam, oferowania funkcji mediów społecznościowych i analizowania ruchu na stronie.",
functionality_storage_title: "Ciasteczka funkcjonalności",
personalization_storage_title: "Ciasteczka personalizacji",
security_storage_title: "Ciasteczka bezpieczeństwa",
button_title: "Zapisz wybrane",
accept_all_button_title: "Zaakceptuj wszystko",
refuse_all_button_title: "Odrzuć wszystko",
consent_text: "Ta strona używa ciasteczek. Używamy ciasteczek do personalizacji treści i reklam, oferowania funkcji mediów społecznościowych i analizowania naszego ruchu.",
consent_link: "<a href='https://policies.google.com/privacy' target='_blank'>Dowiedz się więcej</a>",
},
sl: {
title: "Vaše soglasje",
title: "Privolitev za uporabo osebnih podatkov",
necessary_cookies_title: "Nujni piškotki",

@@ -319,19 +432,29 @@ ad_storage_title: "Oglaševalski piškotki",

analytics_storage_title: "Analitični piškotki",
button_title: "Shrani nastavitve",
consent_text: "Ta spletna stran uporablja piškotke. Piškotke uporabljamo za personalizacijo vsebine in oglasov, omogočanje funkcij družbenih omrežij in analizo prometa.",
functionality_storage_title: "Piškotki funkcionalnosti",
personalization_storage_title: "Piškotki personalizacije",
security_storage_title: "Piškotki varnosti",
button_title: "Shrani izbrano",
accept_all_button_title: "Sprejmi vse",
refuse_all_button_title: "Zavrni vse",
consent_text: "Ta spletna stran uporablja piškotke. Uporabljamo piškotke za prilagajanje vsebine in oglasov, zagotavljanje funkcij socialnih medijev in analizo prometa.",
consent_link: "<a href='https://policies.google.com/privacy' target='_blank'>Več informacij</a>",
},
cs: {
title: "Váš souhlas",
title: "Souhlas s používáním osobních údajů",
necessary_cookies_title: "Nezbytné cookies",
ad_storage_title: "Reklamní cookies",
ad_user_data_title: "Použití reklamních dat",
ad_user_data_title: "Využití reklamních dat",
ad_personalization_title: "Personalizace reklam",
analytics_storage_title: "Analytické cookies",
button_title: "Uložit nastavení",
consent_text: "Tato webová stránka používá cookies. Používáme cookies k personalizaci obsahu a reklam, k poskytování funkcí sociálních médií a k analýze našeho provozu.",
functionality_storage_title: "Funkční cookies",
personalization_storage_title: "Cookies pro personalizaci",
security_storage_title: "Bezpečnostní cookies",
button_title: "Uložit vybrané",
accept_all_button_title: "Přijmout vše",
refuse_all_button_title: "Odmítnout vše",
consent_text: "Tento web používá cookies. Cookies používáme k personalizaci obsahu a reklam, k poskytování funkcí sociálních sítí a k analýze našeho provozu.",
consent_link: "<a href='https://policies.google.com/privacy' target='_blank'>Více informací</a>",
},
nl: {
title: "Uw toestemming",
title: "Toestemming voor het gebruik van persoonsgegevens",
necessary_cookies_title: "Noodzakelijke cookies",

@@ -342,8 +465,13 @@ ad_storage_title: "Advertentiecookies",

analytics_storage_title: "Analytische cookies",
button_title: "Instellingen opslaan",
consent_text: "Deze website gebruikt cookies. We gebruiken cookies om content en advertenties te personaliseren, om functies voor sociale media te bieden en om ons verkeer te analyseren.",
consent_link: "<a href='https://policies.google.com/privacy' target='_blank'>Meer leren</a>",
functionality_storage_title: "Functionaliteitscookies",
personalization_storage_title: "Personalisatiecookies",
security_storage_title: "Beveiligingscookies",
button_title: "Geselecteerde opslaan",
accept_all_button_title: "Accepteer alles",
refuse_all_button_title: "Weiger alles",
consent_text: "Deze website gebruikt cookies. We gebruiken cookies om content en advertenties te personaliseren, om sociale mediafuncties te bieden en om ons verkeer te analyseren.",
consent_link: "<a href='https://policies.google.com/privacy' target='_blank'>Meer weten</a>",
},
is: {
title: "Þitt samþykki",
title: "Samþykki fyrir notkun persónuupplýsinga",
necessary_cookies_title: "Nauðsynlegar kökur",

@@ -354,17 +482,43 @@ ad_storage_title: "Auglýsingakökur",

analytics_storage_title: "Greiningarkökur",
button_title: "Vista stillingar",
functionality_storage_title: "Virknikökur",
personalization_storage_title: "Sérsniðnar kökur",
security_storage_title: "Öryggiskökur",
button_title: "Vista val",
accept_all_button_title: "Samþykkja allt",
refuse_all_button_title: "Hafna öllu",
consent_text: "Þessi vefsíða notar kökur. Við notum kökur til að sérsníða efni og auglýsingar, bjóða upp á samfélagsmiðlaeiginleika og greina umferð okkar.",
consent_link: "<a href='https://policies.google.com/privacy' target='_blank'>Lærðu meira</a>",
consent_link: "<a href='https://policies.google.com/privacy' target='_blank'>Læra meira</a>",
},
fr: {
title: "Votre consentement",
title: "Consentement pour l'utilisation des données personnelles",
necessary_cookies_title: "Cookies nécessaires",
ad_storage_title: "Cookies publicitaires",
ad_user_data_title: "Utilisation des données publicitaires",
ad_personalization_title: "Personnalisation des annonces",
ad_personalization_title: "Personnalisation des publicités",
analytics_storage_title: "Cookies analytiques",
button_title: "Sauvegarder les paramètres",
functionality_storage_title: "Cookies de fonctionnalité",
personalization_storage_title: "Cookies de personnalisation",
security_storage_title: "Cookies de sécurité",
button_title: "Sauvegarder la sélection",
accept_all_button_title: "Tout accepter",
refuse_all_button_title: "Tout refuser",
consent_text: "Ce site utilise des cookies. Nous utilisons des cookies pour personnaliser le contenu et les annonces, offrir des fonctionnalités de médias sociaux et analyser notre trafic.",
consent_link: "<a href='https://policies.google.com/privacy' target='_blank'>En savoir plus</a>",
},
hu: {
title: "Hozzájárulás a személyes adatok használatához",
necessary_cookies_title: "Szükséges sütik",
ad_storage_title: "Hirdetési sütik",
ad_user_data_title: "Hirdetési adatok használata",
ad_personalization_title: "Hirdetések személyre szabása",
analytics_storage_title: "Analitikai sütik",
functionality_storage_title: "Funkcionalitás sütik",
personalization_storage_title: "Személyre szabási sütik",
security_storage_title: "Biztonsági sütik",
button_title: "Kiválasztottak mentése",
accept_all_button_title: "Összes elfogadása",
refuse_all_button_title: "Összes elutasítása",
consent_text: "Ez a weboldal sütiket használ. Sütiket használunk a tartalom és hirdetések személyre szabásához, a közösségi média funkciók biztosításához és forgalmunk elemzéséhez.",
consent_link: "<a href='https://policies.google.com/privacy' target='_blank'>Tudj meg többet</a>",
},
// Add other languages...

@@ -371,0 +525,0 @@ };

{
"name": "fer-cookie-bot",
"version": "1.0.0",
"version": "1.1.0",
"description": "FerCookieBot is JavaScript solution designed for website owners to manage user consents for cookies and tracking technologies, ensuring compliance with data protection regulations like GDPR and CCPA. It now seamlessly integrates with both Google Consent Mode v2 and Facebook Pixel, offering dynamic consent handling and a respectful, legal approach to user data across major advertising platforms.",

@@ -5,0 +5,0 @@ "main": "fer-cookiebot.js",

@@ -47,12 +47,12 @@ # FerCookieBot: JavaScript Consent Management for Google Consent v2 and Facebook Tracking

import FerCookieBot from './path/to/fer-cookiebot.js';
const cookieBotOptions = {
// Your customization options / translations
};
/* ADD YOUR GTAG ID, PIXEL_ID, OPTIONS - CREATES GTAG/GA4 TAG, PIXEL TAG AND INITIALIZE COOKIES */
const cookieBot = new FerCookieBot('YOUR_GOOGLE_TAG_ID');
/* const cookieBot = new FerCookieBot('YOUR_GOOGLE_TAG_ID', 'YOUR_FACEBOOK_PIXEL_ID', cookieBotOptions); */
<script type="module">
import FerCookieBot from './js/fer-cookiebot.min.js';
const cookieBotOptions = {
// Your customization options / translations
};
/* ADD YOUR GTAG ID, PIXEL_ID, OPTIONS - CREATES GTAG/GA4 TAG, PIXEL TAG AND INITIALIZE COOKIES */
const cookieBot = new FerCookieBot('YOUR_GOOGLE_TAG_ID');
/* const cookieBot = new FerCookieBot('YOUR_GOOGLE_TAG_ID', 'YOUR_FACEBOOK_PIXEL_ID', cookieBotOptions); */
</script>
## Multi-Language Support

@@ -76,2 +76,3 @@

- French (fr)
- Hungarian (hu)
- Croatian (hr)

@@ -84,3 +85,3 @@

const cookieBotOptions = {
title: "Your Consent Title",
title: "Consent for the Use of Personal Data",
necessary_cookies_title: "Necessary Cookies",

@@ -91,4 +92,9 @@ ad_storage_title: "Advertising Cookies",

analytics_storage_title: "Analytics Cookies",
button_title: "Save Settings",
consent_text: "This website uses cookies. We use cookies to personalize content and ads, provide social media features, and analyze our traffic.",
functionality_storage_title: "Functionality Cookies",
personalization_storage_title: "Personalization Cookies",
security_storage_title: "Security Cookies",
button_title: "Save Selected",
accept_all_button_title: "Accept All",
refuse_all_button_title: "Refuse All",
consent_text: "This website uses cookies. We use cookies to personalize content and ads, to provide social media features, and to analyze our traffic.",
consent_link: "<a href='https://policies.google.com/privacy' target='_blank'>Learn More</a>",

@@ -95,0 +101,0 @@ };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc