Switas联系我们

免费 Consent v2 生成器

选择您的通知横幅
同意类型
调色板

轻松简化合规

Switas Consent Widget v2 是管理网站用户同意的终极解决方案。我们免费、开源的小组件可确保您遵守隐私法律,同时提供流畅的用户体验。

如何在您的网站上集成免费 Cookie 同意

  1. 复制上方第 3 步中生成的代码,并将其添加到您的网站。
  2. 将 type="text/javascript" 改为 type="text/plain",以标记您正在使用的所有 JavaScript <script>。
  3. 为每个已标记的 <script> 添加相应的同意级别:
    • data-cookie-consent="strictly-necessary":适用于无论用户如何选择都会加载的严格必要脚本
    • data-cookie-consent="functionality":适用于功能性脚本,例如语言偏好脚本
    • data-cookie-consent="tracking":适用于追踪脚本,例如 Google Analytics 4
    • data-cookie-consent="targeting":适用于定向脚本,例如 Google Ads 再营销、Meta Pixel

使用示例

<!-- Login Cookies -->
<script type="text/plain" src="/js/login-session.js"></script>
<!-- Google Analytics -->
<script type="text/plain">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', GOOGLE_PROPERTY_ID_GOES_HERE, 'auto');
ga('send', 'pageview');
</script>

为什么选择 Switas Consent Widget v2?

  • 免费使用:始终免费,也欢迎咨询集成事宜。请在 Github 查看:https://github.com/switaslabs/switas-consent-v2
  • 轻松集成:按照易于遵循的说明,几分钟内即可添加到您的网站。
  • 可定制的设计:可根据您网站的外观和风格进行调整。
  • 用户友好的界面:为用户提供清晰的选项,以给予或撤回同意。
  • 符合法规:符合 GDPR、CCPA 及其他主要隐私法律。

主要功能

  • 设置简便:安装过程快速而简单。
  • 灵活定制:可调整颜色、字体和文字,以契合您的品牌。
  • 响应式设计:在所有设备上都能流畅运行。
  • 分析集成:追踪用户的同意和偏好。
  • 多语言支持:提供多种语言选项,服务全球受众。

管理用户同意

让用户轻松接受、拒绝或自定义其隐私设置。确保符合最新的隐私法规。此小组件的理念与实现基于 Free Cookie Consent 工具

需要帮助?

请查阅我们的文档,获取详细说明和故障排除提示。如有任何问题,欢迎随时联系我们。

关于 Switas

在 Switas,我们致力于提供创新解决方案,帮助企业在数字环境中成长和繁荣。我们对隐私和用户体验的承诺,驱动我们打造既强大又易用的工具。

预览 Cookie 同意
预览 Cookie 同意
"use strict"; var _BASE_URL = ''; var script_config = void 0, user_scripts = [], use_php = !0, php_result_path = _BASE_URL + "consent-preview.php", properties_changed = document.createEvent("Event"); function create_demo(b) { for (var c = document.querySelectorAll("iframe"), a = 0; a < c.length; a++) { var d = c[a]; !0 === use_php ? (d.src = php_result_path + "?data=" + b64EncodeUnicode(b)) : (d.src = _BASE_URL + "result/" + b64EncodeUnicode(b)); } } function b64EncodeUnicode(a) { return btoa( encodeURIComponent(a).replace(/%([0-9A-F]{2})/g, function (b, a) { return String.fromCharCode("0x" + a); }) ); } function clean_script_code_types(a) { return (a = (a = a.replace(new RegExp(" type=('|\")(.*?)('|\")", "g"), "")).replace(new RegExp("=('|\")(.*?)('|\")", "g"), "")); } function prepare_script_code(a, b) { return a.replace(new RegExp("" + d.type + ")"; var c = document.createElement("button"); c.classList.add("btn"), c.classList.add("btn-primary"), (c.innerHTML = "Delete"), b.appendChild(e), b.appendChild(c), a.appendChild(b), c.addEventListener("click", function () { delete user_scripts[f], display_scripts(), document.dispatchEvent(properties_changed); }); }); } properties_changed.initEvent("properties_changed", !0, !0), document.addEventListener("properties_changed", function () { var a = JSON.stringify(script_config), b = _BASE_URL.replace("http:", ""); b = b.replace("https:", ""); var c = compile_user_scripts(); (document.querySelector("#user_code").innerHTML = '\n<\/script>\n\ndocument.addEventListener(\'DOMContentLoaded\', function () {\ncookieconsent.run(' + a + ");\n});\n<\/script>" + c + '\n\nUpdate cookies preferences\n'), create_demo(a); }), (function () { script_config = { notice_banner_type: "headline", consent_type: "express", palette: "dark", language: "en", page_load_consent_levels: ["strictly-necessary"] }; var d = document.querySelector("#website_name"); d.addEventListener("input", function () { (script_config.website_name = d.value), document.dispatchEvent(properties_changed); }); var e = document.querySelectorAll('[name="notice_banner"]'); [].forEach.call(e, function (a) { a.addEventListener("change", function () { (script_config.notice_banner_type = a.value), document.dispatchEvent(properties_changed); }); }); var f = document.querySelectorAll('[name="consent_type"]'); [].forEach.call(f, function (a) { a.addEventListener("change", function () { (script_config.consent_type = a.value), "implied" == a.value ? (script_config.page_load_consent_levels = ["strictly-necessary", "functionality", "tracking", "targeting"]) : "express" == a.value && (script_config.page_load_consent_levels = ["strictly-necessary"]), document.dispatchEvent(properties_changed); }); }); var b = document.querySelectorAll('input[name="palette"]'); for (let a = 0; a < b.length; a++) { let g = b[a]; g.addEventListener("click", function () { (script_config.palette = g.value), document.dispatchEvent(properties_changed); }); } var h = document.querySelector('[name="language"]'); h.addEventListener("change", function () { (script_config.language = h.value), document.dispatchEvent(properties_changed); }); var i = document.querySelector("#include_privacy_policy"), j = document.querySelector("#privacy_policy_link"), k = document.querySelector("#privacy_policy_link_input"); (j.style.display = "none"), i.addEventListener("change", function () { !0 === i.checked ? ((j.style.display = "block"), (k.value = "")) : (delete script_config.website_privacy_policy_url, document.dispatchEvent(properties_changed), (j.style.display = "none")); }), k.addEventListener("input", function () { (script_config.website_privacy_policy_url = k.value), document.dispatchEvent(properties_changed); }); var c = document.querySelector("#addUserScript"); c && c.addEventListener("click", function () { var c = document.querySelector('[name="script_name"]'), a = c.value, b = document.querySelector('[name="script_type"]:checked'), d = "strictly-necessary"; d = null !== b ? b.value || "strictly-necessary" : (b = document.querySelector('[name="script_type"]')).value; var e = document.querySelector('[name="script_code"]'), f = e.value, h = f.indexOf(" -1) { (g.innerHTML = ""), a.length < 1 && (a = "Unnamed script"); var i = clean_script_code_types(f); user_scripts.push({ name: a, type: d, code: i }), (c.value = ""), (e.value = ""), display_scripts(), document.dispatchEvent(properties_changed); } else g.innerHTML = "Invalid code error"; }), (script_config.notice_banner_reject_button_hide = !1), (script_config.preferences_center_close_button_hide = !1), (script_config.page_refresh_confirmation_buttons = !1), document.dispatchEvent(properties_changed); })(); document.getElementById('user-code-copy-button').addEventListener('click', function(e) { var clipboard = new ClipboardJS('#user-code-copy-button', { text: function(trigger) { return document.getElementById('user_code').value; } }); clipboard.on('success', function(e) { alert('Copied.'); }); });

更多免费工具

全部工具 →

让我们一起打造 下一个项目。

联系我们