<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rajneesh Aka Raj</title>
    <description>The latest articles on DEV Community by Rajneesh Aka Raj (@chapeee).</description>
    <link>https://dev.to/chapeee</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1296267%2Fa78f8e1c-a8f0-4a8b-883a-57586911a8fb.jpeg</url>
      <title>DEV Community: Rajneesh Aka Raj</title>
      <link>https://dev.to/chapeee</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chapeee"/>
    <language>en</language>
    <item>
      <title>Your cookie banner says Reject. Does your code listen?</title>
      <dc:creator>Rajneesh Aka Raj</dc:creator>
      <pubDate>Tue, 24 Nov 2026 05:00:15 +0000</pubDate>
      <link>https://dev.to/chapeee/your-cookie-banner-says-reject-does-your-code-listen-2k9c</link>
      <guid>https://dev.to/chapeee/your-cookie-banner-says-reject-does-your-code-listen-2k9c</guid>
      <description>&lt;p&gt;Most cookie banners look fine. You click &lt;strong&gt;Reject&lt;/strong&gt;, the banner goes away, and everyone moves on. But the banner is only half the job. The other half is your code: every analytics tag, pixel and embed has to &lt;em&gt;wait&lt;/em&gt; for that choice. Often it doesn't.&lt;/p&gt;

&lt;p&gt;This isn't rare. A 2025 study found that about half of websites send a tracking cookie to a third party before the visitor has consented (&lt;a href="https://petsymposium.org/popets/2025/popets-2025-0138.pdf" rel="noopener noreferrer"&gt;PETS 2025&lt;/a&gt;). In 2025 Healthline agreed to a $1.55M settlement, partly because its banner didn't actually turn off tracking cookies (&lt;a href="https://www.cmswire.com/customer-experience/the-new-customer-data-privacy-risk-consent-that-looks-compliant" rel="noopener noreferrer"&gt;CMSWire&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;This post covers how to check your own site in five minutes, the three patterns that fix most leaks, and how I now get an AI coding assistant to do the fix over MCP, with me approving every change.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check your site in five minutes (no tools needed)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open a private window, so you start with no cookies and no saved choice.&lt;/li&gt;
&lt;li&gt;Open DevTools, go to &lt;strong&gt;Network&lt;/strong&gt;, and tick &lt;strong&gt;Preserve log&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Load your page and &lt;strong&gt;don't touch the banner&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;In the filter box, try &lt;code&gt;collect&lt;/code&gt;, &lt;code&gt;gtag&lt;/code&gt;, &lt;code&gt;fbevents&lt;/code&gt;, &lt;code&gt;pixel&lt;/code&gt;, &lt;code&gt;clarity&lt;/code&gt;, &lt;code&gt;hotjar&lt;/code&gt;, &lt;code&gt;tiktok&lt;/code&gt;. Anything that shows up here loaded &lt;strong&gt;before consent&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Reject&lt;/strong&gt;, reload, and filter again.&lt;/li&gt;
&lt;li&gt;Check &lt;strong&gt;Application → Cookies&lt;/strong&gt; too. &lt;code&gt;_ga&lt;/code&gt;, &lt;code&gt;_gid&lt;/code&gt;, &lt;code&gt;_fbp&lt;/code&gt; or &lt;code&gt;_clck&lt;/code&gt; showing up after Reject means something isn't waiting.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If step 4 or 5 shows requests, your banner is decoration. The good news: the fix is usually small.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why it happens
&lt;/h2&gt;

&lt;p&gt;Almost always it's one of these:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A tag pasted straight into &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt;.&lt;/strong&gt; The browser runs &lt;code&gt;&amp;lt;script src="https://www.googletagmanager.com/gtag/js?id=G-XXXX"&amp;gt;&lt;/code&gt; the moment it parses it. Your banner hasn't even loaded yet.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An SDK started from your bundle.&lt;/strong&gt; &lt;code&gt;posthog.init()&lt;/code&gt; or &lt;code&gt;analytics.load()&lt;/code&gt; in &lt;code&gt;_app.tsx&lt;/code&gt; / &lt;code&gt;main.ts&lt;/code&gt; runs on page load, whatever the visitor chose.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Embeds.&lt;/strong&gt; A YouTube iframe or a map sets cookies as soon as it renders.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A tag manager with no consent rules.&lt;/strong&gt; GTM loads, and every tag inside it fires on "All pages".&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The three patterns that fix most leaks
&lt;/h2&gt;

&lt;p&gt;These are the patterns most consent tools support in some form. The attribute names below are Kiescy's, but the idea is the same everywhere.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Scripts: make them inert until consent.&lt;/strong&gt; A script with &lt;code&gt;type="text/plain"&lt;/code&gt; is never run by the browser. The consent tool switches it on when the visitor allows that category.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- before --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script&lt;/span&gt; &lt;span class="na"&gt;async&lt;/span&gt; &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://www.googletagmanager.com/gtag/js?id=G-XXXX"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- after: tag the loader AND its inline config --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"text/plain"&lt;/span&gt; &lt;span class="na"&gt;data-pira-category&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"analytics"&lt;/span&gt; &lt;span class="na"&gt;async&lt;/span&gt;
        &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://www.googletagmanager.com/gtag/js?id=G-XXXX"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"text/plain"&lt;/span&gt; &lt;span class="na"&gt;data-pira-category&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"analytics"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dataLayer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dataLayer&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;gtag&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;dataLayer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arguments&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nf"&gt;gtag&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'js'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nf"&gt;gtag&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'config'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'G-XXXX'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In React or Next.js, check the &lt;em&gt;rendered&lt;/em&gt; HTML: some components drop or rewrite the &lt;code&gt;type&lt;/code&gt; attribute.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Iframes and pixels: move &lt;code&gt;src&lt;/code&gt; out of the way.&lt;/strong&gt; The browser can't contact a server it doesn't have an address for.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;iframe&lt;/span&gt; &lt;span class="na"&gt;data-pira-category&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"social"&lt;/span&gt;
        &lt;span class="na"&gt;data-pira-src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://www.youtube.com/embed/VIDEO_ID"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. SDKs started in code: wrap the init.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pira&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;when&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"analytics"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;posthog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"KEY"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;api_host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://eu.posthog.com"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// If this can run before the consent script has loaded, queue it:&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;piraQueue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;piraQueue&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pira&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;pira&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;when&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"advertising"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;startAds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And if a visitor withdraws consent later, a script that already ran can't be unloaded. Call the SDK's opt-out (&lt;code&gt;posthog.opt_out_capturing()&lt;/code&gt;) or reload the page.&lt;/p&gt;

&lt;h2&gt;
  
  
  Letting an AI assistant do it, safely
&lt;/h2&gt;

&lt;p&gt;None of this is hard. It's just tedious: you have to find every tag across layouts, components and third-party snippets, and know which category each tracker belongs to. That's a good job for an AI coding assistant, &lt;em&gt;if&lt;/em&gt; it knows what's actually wrong on the live site. Guessing from the code alone misses tags that come from a CMS, a tag manager or a plugin.&lt;/p&gt;

&lt;p&gt;This is why I built an MCP server for &lt;a href="https://kiescy.com" rel="noopener noreferrer"&gt;Kiescy&lt;/a&gt;, the privacy compliance tool I work on. (Disclosure: I'm the founder.) Kiescy visits your live site in a real browser as a first-time visitor, records what loads before any choice, clicks Reject, and records what still loads. The MCP server hands those findings to your assistant:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;What the assistant gets&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;list_issues&lt;/code&gt; / &lt;code&gt;get_issue&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;What loaded, on which page, which category it belongs to, and the suggested fix&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;get_fix_prompt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Step-by-step instructions for your codebase, including the tagging rules above&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;get_consent_api&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;How new code should wait for consent, so the next tag you add doesn't leak&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;run_check&lt;/code&gt; / &lt;code&gt;get_check&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Re-checks the live site after you deploy, and closes the issues that are gone&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;It also checks accessibility (WCAG A/AA with axe-core) and security headers, and the same tools cover those.&lt;/p&gt;

&lt;p&gt;Connecting it in Claude Code is one line (Cursor and VS Code configs are in the &lt;a href="https://github.com/chapeee/kiescy-mcp" rel="noopener noreferrer"&gt;repo&lt;/a&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude mcp add --transport http kiescy https://mcp.kiescy.com/mcp \
  --header &lt;span class="s2"&gt;"Authorization: Bearer YOUR_API_KEY"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then I just say: &lt;em&gt;"Fix the Kiescy issues on this site."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The part I cared most about is that the assistant &lt;strong&gt;doesn't get to just start editing&lt;/strong&gt;. The server tells it to search the code, show a plan (files and changes) and wait for an explicit OK. The key only covers one website, and through MCP the assistant can't change the banner, account settings or consent records. After I deploy, it calls &lt;code&gt;run_check&lt;/code&gt;, and the issue only closes if the live site no longer shows it.&lt;/p&gt;

&lt;p&gt;There's a second server, &lt;code&gt;https://mcp.kiescy.com/mcp/documents&lt;/code&gt;, for legal pages. It asks about your business a few questions at a time, drafts or imports your privacy policy, terms and cookie policy, and only publishes after a one-time confirmation in the chat. It never guesses things like where your customers are or what you collect.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Run the five-minute DevTools check above on your own site. It costs nothing.&lt;/li&gt;
&lt;li&gt;Or run &lt;a href="https://kiescy.com/check" rel="noopener noreferrer"&gt;Kiescy's free check&lt;/a&gt; (no sign-up) to see what your site loads before a visitor agrees.&lt;/li&gt;
&lt;li&gt;To connect your assistant, create a free account (Kiescy is free during early access) and copy the key from &lt;strong&gt;Fix with AI&lt;/strong&gt;. Setup guide: &lt;a href="https://kiescy.com/product/fix-with-ai" rel="noopener noreferrer"&gt;kiescy.com/product/fix-with-ai&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'd love feedback from anyone building MCP servers or dealing with consent on client sites. What would you want an assistant to be allowed to do here, and what should always need a human?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Kiescy's checks help you comply. They aren't legal advice.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>privacy</category>
      <category>mcp</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
