Back to Blog
Use Cases

Ad Verification with Cloud Browsers: Ensuring Ad Quality

How to use cloud browsers for ad verification, including geo-targeted ad checking, malvertising detection, and brand safety monitoring.

Introduction

Ad verification ensures that digital advertisements appear correctly, in the right locations, to the right audiences, and without fraud. Cloud browsers are ideal for ad verification because they can simulate real user browsers from any geographic location with authentic fingerprints.

Why Cloud Browsers for Ad Verification

Geographic Accuracy

Ads are targeted by geography. To verify ads in different regions, you need browsers that genuinely appear to be in those locations:

const regions = [
  { name: 'New York', proxy: 'socks5h://user:pass@ny:1080' },
  { name: 'London', proxy: 'socks5h://user:pass@london:1080' },
  { name: 'Tokyo', proxy: 'socks5h://user:pass@tokyo:1080' },
];

async function verifyAdByRegion(adUrl) {
  for (const region of regions) {
    const browser = await puppeteer.connect({
      browserWSEndpoint:
        `wss://bots.win/ws?apiKey=YOUR_API_KEY&proxy=${encodeURIComponent(region.proxy)}`,
    });

    const page = await browser.newPage();
    await page.goto(adUrl, { waitUntil: 'networkidle2' });

    // Capture ad as displayed in this region
    await page.screenshot({ path: `ad-${region.name}.png` });

    // Extract ad content
    const adContent = await page.evaluate(() => {
      const ads = document.querySelectorAll('[data-ad], iframe[id*="google_ads"]');
      return Array.from(ads).map(ad => ({
        visible: ad.offsetParent !== null,
        width: ad.offsetWidth,
        height: ad.offsetHeight,
        src: ad.src || ad.getAttribute('data-src'),
      }));
    });

    console.log(`${region.name}:`, adContent);
    await browser.close();
  }
}

Real Browser Environment

Ad platforms detect automation and may serve different content to bots. Cloud browsers with authentic fingerprints receive the same ads as real users.

Device Diversity

Verify ads across device types:

// Mobile ad verification
const mobileBrowser = await puppeteer.connect({
  browserWSEndpoint: 'wss://bots.win/ws?apiKey=YOUR_API_KEY&device=mobile-android',
});

// Desktop ad verification
const desktopBrowser = await puppeteer.connect({
  browserWSEndpoint: 'wss://bots.win/ws?apiKey=YOUR_API_KEY&device=desktop-windows',
});

Ad Verification Tasks

Placement Verification

Confirm ads appear in the correct positions:

async function verifyPlacement(page, adSelector, expectedPosition) {
  const adElement = await page.$(adSelector);
  if (!adElement) {
    return { status: 'missing', message: 'Ad element not found' };
  }

  const box = await adElement.boundingBox();
  const isAboveFold = box.y < (await page.evaluate(() => window.innerHeight));

  return {
    status: 'found',
    position: { x: box.x, y: box.y },
    size: { width: box.width, height: box.height },
    aboveFold: isAboveFold,
    meetsRequirements: isAboveFold === expectedPosition.aboveFold,
  };
}

Brand Safety

Check that ads do not appear alongside inappropriate content:

async function checkBrandSafety(page) {
  const pageContent = await page.evaluate(() => document.body.textContent.toLowerCase());

  const unsafeCategories = {
    violence: ['violence', 'murder', 'assault', 'weapon'],
    adult: ['adult content', 'explicit', 'nsfw'],
    hate: ['hate speech', 'discrimination', 'extremism'],
    drugs: ['illegal drugs', 'narcotics'],
  };

  const flags = {};
  for (const [category, keywords] of Object.entries(unsafeCategories)) {
    const matches = keywords.filter(kw => pageContent.includes(kw));
    if (matches.length > 0) {
      flags[category] = matches;
    }
  }

  return {
    safe: Object.keys(flags).length === 0,
    flags,
  };
}

Viewability Measurement

Check if ads meet viewability standards:

async function measureViewability(page, adSelector) {
  return page.evaluate((selector) => {
    const ad = document.querySelector(selector);
    if (!ad) return { viewable: false, reason: 'not found' };

    const rect = ad.getBoundingClientRect();
    const viewportHeight = window.innerHeight;
    const viewportWidth = window.innerWidth;

    // IAB standard: 50% of pixels visible for 1 second
    const visibleWidth = Math.min(rect.right, viewportWidth) - Math.max(rect.left, 0);
    const visibleHeight = Math.min(rect.bottom, viewportHeight) - Math.max(rect.top, 0);
    const visibleArea = Math.max(0, visibleWidth) * Math.max(0, visibleHeight);
    const totalArea = rect.width * rect.height;
    const visibilityRatio = totalArea > 0 ? visibleArea / totalArea : 0;

    return {
      viewable: visibilityRatio >= 0.5,
      visibilityRatio,
      inViewport: rect.top < viewportHeight && rect.bottom > 0,
    };
  }, adSelector);
}

Best Practices

  1. Use regional proxies to verify geo-targeted ads accurately
  2. Test across device types since mobile and desktop ads differ
  3. Capture screenshots for visual verification and audit trails
  4. Monitor network requests to detect malvertising redirects
  5. Run regular checks since ad placements change frequently
  6. Use residential proxies since ad platforms may filter datacenter IPs
#ad-verification#advertising#brand-safety#monitoring