REDDIT 原始帖子

How to autoblock Google Maps iframe cookies in my website??

I created a website a while ago and I want it to be GDPR compliant. I'm trying to solve this by using CookieYes service but it doesn't seem to detect the Google Maps cookies I may have due to an embed on one of the pages I have. I also have Instagram,…

原帖正文r/webdev

I created a website a while ago and I want it to be GDPR compliant. I'm trying to solve this by using CookieYes service but it doesn't seem to detect the Google Maps cookies I may have due to an embed on one of the pages I have. I also have Instagram, Facebook and X (Twitter) embeds on another page, and want that also to be compliant. Any solutions are welcome. Is there a somewhat simple way to solve this?

已收录讨论

5 条评论

u/webdev-ModTeam

Your post/comment has been determined to be a low-effort post or comment. This includes title-only posts, easily searchable questions, vague/open-ended discussion prompts, LLM generated posts or comments, and posts/comments that do not provide enough context for meaningful replies or discussion.

u/aaresvictor

CookieYes can't catch it because a Maps embed is a cross-origin iframe. No CMP can block or read cookies inside it. The fix is to not load the iframe until consent: replace it with a placeholder, keep the URL in a data attribute, and set src only after the user accepts. <div data-src="https://www.google.com/maps/embed?pb=..."> <button onclick="load(this)">Load map</button> </div> function load(btn){ const h = btn.parentElement, f = document.createElement('iframe'); f.src = h.dataset.src; f.loading = 'lazy'; h.replaceWith(f); } Same for the Instagram/FB/X embeds: don't inject their embed.js until consent. Maps has no cookieless mode like youtube-nocookie.com, so this click-to-load facade is the only compliant option.

u/f314

As others have said, don't show embedded third party content until your users have consented to the relevant cookies. Should be as simple as an if statement that renders a placeholder if consent is not given and the actual iframe if it is.

u/AmazedStardust

iframes are isolated so that's probably why CookieYes can't stop them. As best I can tell, you're responsible if you send the user's IP address to a third party to load that embed, so your best option would be to ask for consent before loading them

u/[deleted]

这条评论已被删除。