---
title: "Track Competitor Facebook Ads Automatically"
description: "Build a daily job that snapshots competitors' Facebook ads, detects new launches and stopped ads by ad id, and measures how long each ad runs."
url: https://scrapeadlibrary.com/blog/track-competitor-facebook-ads
markdown: https://scrapeadlibrary.com/blog/track-competitor-facebook-ads.md
---

# How to Track Competitor Facebook Ads Automatically

Monitoring · Published November 26, 2026 · 6 min read

Looking at a competitor's ads once tells you what they run today. Looking every day tells you when they launch a campaign, which tests they kill within a week and which creatives survive for months. This guide builds that tracker: a small script that saves a daily snapshot of each competitor's active ads, compares it with yesterday's by ad id, and reports what is new and what stopped.

## What a tracker gives you that a snapshot cannot

The Ad Library shows the present. History, the most useful part of competitor intelligence, is something you have to record yourself. With a daily snapshot you can answer questions the library alone cannot:

- **When did they launch?** A burst of new ads on the same landing page is a campaign start, often tied to a product launch or a sale.
- **What did they kill?** Ads that appear and disappear within a few days are tests that lost. A competitor pays for that learning; you get it for the price of an API call.
- **What survives?** An ad still running after 60 or 90 days is almost certainly profitable. Longevity is the best public proxy for performance there is.
- **How fast do they iterate?** The number of new ads per week tells you how big and how active their creative team is.

The API already gives every ad a `started_at` date (and `ended_at` once it stopped) plus a derived `days_active`, so even your first snapshot carries some history. The daily diff adds what the dates cannot: the exact day an ad entered or left the active list, according to your own observation.

## The data you need for each ad

Keep the tracker lean. For each ad, store the fields you will compare and report, keyed by the Ad Library `id`, which never changes:

| Field | Why |
| --- | --- |
| `id` | The key of the diff: same id = same ad |
| `started_at` / `ended_at` | Meta's own dates; `ended_at` is null while the ad runs |
| `days_active` | Longevity in whole days, computed for you |
| `collation_id`, `variants_count` | Which creative the ad belongs to and how many variants it has |
| `link_url`, `cta` | Which offer and landing page the ad pushes |
| `body`, `title` | The message, to read the hooks |
| `format`, `platforms` | Video or image, Facebook or Instagram |

Media URLs are not worth storing: they expire after a few days. If you want to keep the creatives of new ads, download the files the day you see them, as the [creatives guide](https://scrapeadlibrary.com/blog/download-facebook-ad-creatives.md) shows.

## Step 1: snapshot the active ads of a competitor

The [page ads endpoint](https://scrapeadlibrary.com/facebook-page-ads-api.md) lists the ads of one advertiser page, 30 per call. For a reliable diff you need the complete active list, so follow `next_cursor` until `has_more` is false, with a cap so a giant advertiser cannot drain your credits. Find the page id with the [advertiser search](https://scrapeadlibrary.com/facebook-advertiser-search-api.md) if you do not have it yet.

```bash
# First page of the active ads of one advertiser in the US
curl -s "https://api.scrapeadlibrary.com/v1/pages/15087023444/ads?status=active&country=US" -H "X-API-Key: $SCRAPEADLIBRARY_API_KEY"
```

## Step 2: the tracking script

The script below keeps one JSON file per competitor with the ads seen in the last run. Each run fetches the current active ads, prints the new ones (not in the file) and the stopped ones (in the file, no longer active), then saves the new snapshot. It needs only `requests` and the standard library.

Python:

```python
import json
import os
import pathlib
import requests

API = "https://api.scrapeadlibrary.com"
HEADERS = {"X-API-Key": os.environ["SCRAPEADLIBRARY_API_KEY"]}
MAX_PAGES = 10  # at most 10 calls per competitor per run
COMPETITORS = {"15087023444": "Competitor A", "115939511520844": "Competitor B"}
STATE = pathlib.Path("ad-tracker")
STATE.mkdir(exist_ok=True)


def active_ads(page_id):
    ads, cursor = {}, None
    for _ in range(MAX_PAGES):
        params = {"status": "active", "country": "US"}
        if cursor:
            params.update(cursor=cursor)
        response = requests.get(f"{API}/v1/pages/{page_id}/ads", params=params, headers=HEADERS, timeout=60)
        response.raise_for_status()
        page = response.json()
        for ad in page["data"]:
            ads[ad["id"]] = {
                "started_at": ad["started_at"],
                "days_active": ad["days_active"],
                "variants_count": ad["variants_count"],
                "link_url": ad["link_url"],
                "title": ad["title"],
                "url": ad["url"],
            }
        if not page["has_more"]:
            return ads, True
        cursor = page["next_cursor"]
    return ads, False  # capped: do not report stopped ads from an incomplete list


for page_id, name in COMPETITORS.items():
    file = STATE / f"{page_id}.json"
    before = json.loads(file.read_text()) if file.exists() else {}
    now, complete = active_ads(page_id)
    new = [ad_id for ad_id in now if ad_id not in before]
    stopped = [ad_id for ad_id in before if ad_id not in now] if complete and before else []
    print(f"{name}: {len(now)} active, {len(new)} new, {len(stopped)} stopped")
    for ad_id in new:
        print("  NEW    ", now[ad_id]["started_at"], now[ad_id]["link_url"], now[ad_id]["url"])
    for ad_id in stopped:
        print("  STOPPED", before[ad_id]["days_active"], "days", before[ad_id]["url"])
    file.write_text(json.dumps(now, indent=2))
```

JavaScript:

```javascript
import fs from "node:fs";

const API = "https://api.scrapeadlibrary.com";
const headers = { "X-API-Key": process.env.SCRAPEADLIBRARY_API_KEY };
const MAX_PAGES = 10;
const competitors = { "15087023444": "Competitor A", "115939511520844": "Competitor B" };
fs.mkdirSync("ad-tracker", { recursive: true });

async function activeAds(pageId) {
  const ads = {};
  let cursor = null;
  for (let i = 0; i < MAX_PAGES; i++) {
    const params = new URLSearchParams({ status: "active", country: "US" });
    if (cursor) params.set("cursor", cursor);
    const url = API + "/v1/pages/{page_id}/ads".replace("{page_id}", pageId) + "?" + params;
    const response = await fetch(url, { headers });
    if (!response.ok) throw new Error("HTTP " + response.status);
    const page = await response.json();
    for (const ad of page.data) {
      ads[ad.id] = { started_at: ad.started_at, days_active: ad.days_active, link_url: ad.link_url, url: ad.url };
    }
    if (!page.has_more) return { ads, complete: true };
    cursor = page.next_cursor;
  }
  return { ads, complete: false };
}

for (const [pageId, name] of Object.entries(competitors)) {
  const file = "ad-tracker/" + pageId + ".json";
  const before = fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, "utf8")) : {};
  const { ads: now, complete } = await activeAds(pageId);
  const added = Object.keys(now).filter((id) => !(id in before));
  const stopped = complete && Object.keys(before).length ? Object.keys(before).filter((id) => !(id in now)) : [];
  console.log(name + ": " + Object.keys(now).length + " active, " + added.length + " new, " + stopped.length + " stopped");
  for (const id of added) console.log("  NEW    ", now[id].started_at, now[id].link_url, now[id].url);
  for (const id of stopped) console.log("  STOPPED", before[id].days_active, "days", before[id].url);
  fs.writeFileSync(file, JSON.stringify(now, null, 2));
}
```

Two details make the output trustworthy. First, stopped ads are only reported when the list is complete: if the run stopped at the page cap, an ad missing from the list may simply be on a later page. Second, a failed call raises instead of saving an empty snapshot, so a temporary error never looks like a competitor switching everything off. Errors are never billed; retry `429` after the `Retry-After` header and `503` after a pause ([error codes](https://scrapeadlibrary.com/docs/errors.md)).

### Confirm a stop and get its real end date

An ad can leave the active list for reasons other than being switched off, for example if it stops being shown in the country you filter on. When a stop matters, fetch the ad with `GET /v1/ads/{ad_id}`: its `status`, `ended_at` and final `days_active` are Meta's own record, and the [ad details endpoint](https://scrapeadlibrary.com/facebook-ad-details-api.md) adds the EU transparency data.

## Step 3: run it every day

A cron entry is enough. This runs the tracker at 7:15 every morning and appends the report to a log:

```bash
# crontab -e
15 7 * * * cd /home/me/tracker && SCRAPEADLIBRARY_API_KEY=sal_your_key python3 track.py >> report.log 2>&1
```

In a team, send the output to Slack or e-mail instead of a log, and only when something changed. GitHub Actions on a schedule, a serverless function or a small VPS all work; the job takes seconds.

## What it costs

Every call costs one credit whatever the number of ads it returns. A competitor with up to 30 active ads costs one call per run; with 90 active ads, three. Tracking five mid-sized competitors once a day is about 150 calls a month: the first 65 are free every month and the rest cost $5 per 1,000 calls ([pricing](https://scrapeadlibrary.com/pricing.md)). Purchased credits stay valid for a year, so a small top-up covers months of tracking.

> Daily is the right frequency for most markets: ads are rarely switched on and off within hours, and a competitor's ads seldom change twice in one day. For a launch week you can run it twice a day.

## Turning the log into insight

After a few weeks the snapshots answer bigger questions. A few analyses worth building:

1. **Launch calendar.** Plot new ads per day per competitor. Peaks line up with sales, product launches and seasons, and they repeat every year.
2. **Survival curve.** For each stopped ad, record its `days_active`. If most ads of a competitor die within 7 days, they test aggressively; the few that pass 30 days are their winners. The [winning ads guide](https://scrapeadlibrary.com/blog/find-winning-facebook-ads.md) explains how to rank them.
3. **Offer rotation.** Group new ads by `link_url` to see which products or landing pages each competitor pushes month by month.
4. **Creative fatigue.** When a long-running creative finally stops, look at what replaced it: that is the competitor's next bet.

For the broader research method (finding competitors, reading hooks and offers), start with [how to spy on competitor Facebook ads](https://scrapeadlibrary.com/blog/spy-on-competitor-facebook-ads.md). If you run this for clients, [ad research for agencies](https://scrapeadlibrary.com/blog/facebook-ad-research-for-agencies.md) shows how to package it as a weekly report.

## Frequently asked questions

### How do I know exactly when a competitor's ad started?

Every ad carries started_at, the date Meta records as the start of delivery, and days_active counts the days since. Your daily snapshots add the day you first saw it, which helps when ads are scheduled in advance.

### Can I track inactive ads too?

Yes. Ask with status=inactive or status=all, optionally with an active_from and active_to window, to list ads that ran at some point in a period, with their started_at and ended_at.

### Does the tracker work for Instagram ads?

Yes. Meta's Ad Library covers Facebook, Instagram, Messenger, Threads and the Audience Network. Add platforms=instagram to the request to track only Instagram placements.

### Will the tracker use up my credits if Meta is temporarily unavailable?

No. Only successful calls are billed. A failed call raises an error in the script, nothing is saved, and the next run picks up normally.

## Related guides

- [How to Spy on Competitor Facebook Ads (Legally, with Data)](https://scrapeadlibrary.com/blog/spy-on-competitor-facebook-ads.md): Find every competitor running Facebook and Instagram ads, list their creatives, hooks, offers and landing pages, and turn the Ad Library into a daily feed.
- [How to Find Winning Facebook Ads for Dropshipping](https://scrapeadlibrary.com/blog/find-winning-facebook-ads.md): Use ad longevity to find winning Facebook ads for dropshipping: days_active, a 0-100 winning_score, and code that ranks the ads of any product niche.
- [How to Scrape the Facebook Ad Library (2026 Guide)](https://scrapeadlibrary.com/blog/how-to-scrape-facebook-ad-library.md): Three ways to get Facebook Ad Library data out as JSON: by hand, with your own scraper, or with an API. Working cURL, Python and JavaScript examples.

[All guides](https://scrapeadlibrary.com/blog.md)

## Try it on your own competitors

Create a free account and get 65 free calls every month, no credit card. One API key works on every endpoint.

[Create a free account](https://scrapeadlibrary.com/auth/sign-up) · [Read the docs](https://scrapeadlibrary.com/docs.md)
