Monitoring

How to Track Competitor Facebook Ads Automatically

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.

Published 6 min read

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:

FieldWhy
idThe key of the diff: same id = same ad
started_at / ended_atMeta's own dates; ended_at is null while the ad runs
days_activeLongevity in whole days, computed for you
collation_id, variants_countWhich creative the ad belongs to and how many variants it has
link_url, ctaWhich offer and landing page the ad pushes
body, titleThe message, to read the hooks
format, platformsVideo 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 shows.

Step 1: snapshot the active ads of a competitor

The page ads endpoint 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 if you do not have it yet.

# 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.

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))

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).

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 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:

# 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). Purchased credits stay valid for a year, so a small top-up covers months of tracking.

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 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. If you run this for clients, ad research for agencies 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

← All guides

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.