
自动生成一个完整的、合规的 Google Consent Mode v2 实现模板,包括 HTML、CSS 和 JavaScript,全干净结构。
打包成一份专业且易用的 Cursor Prompt,让你一贴就能让 Cursor 自动生成一个完整的、合规的 Google Consent Mode v2 实现模板,包括 HTML、CSS 和 JavaScript,全干净结构。
专为 Cursor 优化的 Cookie Consent Mode v2 提示词(自动适配网站风格)
markdownCopyEditI want to add a fully functional Cookie Consent banner that uses Google Consent Mode v2 and matches the visual style of my current website. Here’s what I need: --- ✅ Core functionality: 1. Use `gtag.js` to set default consent values: ```js ad_storage: 'denied', analytics_storage: 'denied', ad_user_data: 'denied', ad_personalization: 'denied'
- Include
wait_for_update,ads_data_redaction, andurl_passthroughoptions. - Load the Google Tag correctly:
- Define
window.dataLayerandgtagfirst. - Set consent before any
gtag('config').
- Define
✅ Cookie banner behavior:
- Show the banner only on first visit (based on
localStorage). - Include two buttons: “Accept” and “Reject”.
- Clicking either one:
- Calls
gtag('consent', 'update', ...) - Saves the choice to localStorage
- Hides the banner
- Calls
- Also add a small “Manage Cookie Preferences” button for resetting choice.
✅ Style and integration:
This is important:
Make sure the banner inherits my site’s existing style:
- Use the same colors, fonts, button styles, spacing, and rounded corners
- Position the banner where it feels natural on my site (bottom, floating, etc.)
- Match typography and visual hierarchy
- Make it responsive like the rest of the site
If I’m using a CSS framework (like Tailwind, Bootstrap, etc.), reuse existing classes from the project.
✅ Structure:
- Use plain HTML + JS unless my project uses a framework (you can infer from current code).
- Wrap all JS inside
DOMContentLoadedto avoid DOM loading issues. - Add comments explaining each part.
Make the code clean and ready to paste directly into my project.
yamlCopyEdit --- ## 🧩 使用说明: - 打开 Cursor 的 Chat 面板(Cmd + K) - 粘贴上面这个提示词 - 它会自动「读懂你项目的风格」,用当前页面/组件的配色、按钮结构来生成弹窗 UI --- ## 📌 小建议(让 Cursor 发挥最大效果): - 在你已有代码文件中运行这个提示(比如你的主页 HTML 或 layout) - 不要在空文件用,Cursor 才能“看到你网站的真实风格” --- 你现在用这版提示词,就能让 Cursor 自动做出一个既合规又长得像你网站亲兄弟的 Cookie 弹窗。
