
Remove cookie banners and ads from website screenshots
A screenshot with a consent dialog across the middle records the dialog, not the page. Two settings keep banners and advertising out of the frame, and there are three fixes for the banner that still gets through.
· 4 min read
Why it matters
A browser that visits a page for the first time is shown everything a first-time visitor is shown: the cookie banner, the newsletter pop-up, the chat bubble, the bar that asks you to open the app. A capture service always arrives as a first-time visitor, so without help every capture has them.
Advertising is a second problem. It is not part of the page you are archiving, and it changes on every load, so a daily capture of a page that did not change still looks different every day. That is noise in an archive, and false alarms if you monitor the page for changes.
Two switches, on by default
Both switches are at the end of the Capture behaviour section of the Web Profile form, and both are on when you create a profile.
- Block ads stops advertising from loading at all. The capture is cleaner, and it finishes faster, because the page is not waiting on ad networks.
- Dismiss pop-ups answers cookie banners, hides known sign-up pop-ups, chat widgets and “open in the app” bars, and closes other overlays with their own close button. It looks again after scrolling, for the ones that only open then.
A third setting, Press Escape, is off by default. It presses the Escape key after the pop-up pass and again after scrolling, for a modal that closes on Escape even when nothing else recognises it.
When a banner gets through
Sites build their consent dialogs in many different ways, so now and then one is not caught. Handle it on the schedule, under Page tweaks:
- Hide these elements, pointed at the banner's container, when you only want it out of the picture. Up to 25 selectors, separated by commas.
- Click this element, pointed at the accept or reject button, when you want the banner really dismissed and the page captured in its state after consent.
- Press Escape on the profile, for a modal that closes when you press Escape in your own browser.
A selector is a promise about somebody else's markup. Look at the first capture after adding one, and check again after the site is redesigned. The advanced selectors page shows how to find one that lasts.
The same thing in the API
The Instant Snap API has the same settings. block_ads and block_pop_ups are true unless you send false, and press_escape is false unless you send true:
{
"url": "https://example.com",
"block_ads": true,
"block_pop_ups": true,
"press_escape": true,
"selectors": {
"hide": "#cookie-banner, .newsletter-modal"
}
}selectors.hide takes CSS selectors, and elements the page adds later are hidden too. There is a selectors.click as well, but for banners prefer hide: a click depends on the button existing and on the click taking effect before the shot.
When to turn blocking off
- You are monitoring the advertising itself: checking that your own campaigns render, or recording which ads a competitor's pages carry.
- Ad blocking breaks the page. Some sites detect a blocker and refuse to show content, or leave a large empty gap where the ad should be.
- The overlay is the point. Capturing your own promotional modal to prove it appeared needs Dismiss pop-ups off.
FAQ
Do I have to turn ad and pop-up blocking on?
No. Block ads and Dismiss pop-ups are both on when you create a Web Profile, and both default to true in the Instant Snap API.
Should I click the accept button or hide the banner?
Hide it, unless you want the page in its state after consent. Hiding works whether or not the banner is interactive, and does not set a consent cookie you did not intend to set.
What happens if my hide selector matches nothing?
Nothing fails. The capture is taken as it is. For Click this element, a capture whose selector matched nothing carries a note that says the click did not happen.
Can I capture a page with its ads on purpose?
Yes. Turn Block ads off, on a copy of the profile so the other schedules that use the original are not changed.