Loading workspace…

Winning Ads Intelligence

This is the exact input and environment shape Scrape uses for the Meta Ad Library pipeline. The current actor is apify/facebook-ads-scraper. Scrape stores the creative, landing page, publisher platforms, and AI enrichment, then matches each ad against products in your database.

Exact actor input

Use this payload when you run the actor directly through Apify API or when validating your category URLs in Apify Console.

{
  "startUrls": [
    {
      "url": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&is_targeted_country=false&media_type=all&search_type=keyword&q=portable%20blender"
    },
    {
      "url": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&is_targeted_country=false&media_type=video&search_type=keyword&q=posture%20corrector"
    }
  ],
  "resultsLimit": 60,
  "onlyTotal": false,
  "includeAboutPage": true,
  "isDetailsPerAd": true,
  "activeStatus": "active",
  "addAudienceData": false
}

Discovery-driven category sourcing

Scrape now derives Meta ad categories dynamically from the category intelligence discovery state in logs/category-discovery-state.json. The worker expands discovered categories into Meta Ad Library keyword URLs automatically, so you no longer need to maintain a full WINNING_ADS_APIFY_CATEGORY_URLS map in env.

If you want to add hand-curated URLs for a specific category, you can still provide an optional partial JSON map like this:

{
  "beauty": [
    "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&is_targeted_country=false&media_type=video&search_type=keyword&q=skincare%20tool"
  ],
  "sports-outdoors": [
    "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&is_targeted_country=false&media_type=video&search_type=keyword&q=fitness%20accessory"
  ]
}

Required environment variables

WINNING_ADS_ENABLED=true
APIFY_TOKEN=apify_api_xxxxx
WINNING_ADS_APIFY_ACTOR_ID=apify~facebook-ads-scraper
WINNING_ADS_HOT_CATEGORIES=home,pet-supplies,beauty,sports-outdoors
WINNING_ADS_RESULTS_LIMIT=60
WINNING_ADS_LIST_LIMIT=18
WINNING_ADS_INTERVAL_HOURS=12
WINNING_ADS_AI_ENRICH_LIMIT=24
WINNING_ADS_ACTIVE_STATUS=active
WINNING_ADS_INCLUDE_ABOUT_PAGE=true
WINNING_ADS_DETAILS_PER_AD=true
WINNING_ADS_AUDIENCE_DETAILS=false
WINNING_ADS_DYNAMIC_CATEGORY_COUNT=12

Apify account and token

You do need an Apify account and a valid Apify API token for this pipeline. Scrape calls the actor through Apify's API endpoint with a Bearer token, so there is no separate Meta API credential in this setup.

  1. Create or log into your Apify account.
  2. Open Apify Console and create a personal API token in your account settings or integrations area.
  3. Paste that token into APIFY_TOKEN on the API deployment.
  4. Test with node src/winningAdsWorker.js --once. If the token is wrong, Apify returns a 401 user-or-token-not-found error.

The current Scrape worker uses Apify's synchronous actor run endpoint pattern /v2/acts/apify~facebook-ads-scraper/run-sync-get-dataset-items and sends the API token in the Authorization: Bearer ... header, which matches Apify's recommended authentication flow.

Optional environment variables

  • WINNING_ADS_APIFY_START_URLS: comma-separated fallback URLs added to every sync. Leave this blank unless you want generic uncategorized exploratory searches.
  • WINNING_ADS_APIFY_CATEGORY_URLS: optional partial JSON map for bespoke category URLs. You do not need to fill it for the pipeline to work, but it improves quality when you want category-specific video-first searches that map cleanly back to your products.
  • WINNING_ADS_AUDIENCE_DETAILS=true: asks the actor for audience details when available, at the cost of slower runs.

How matching works now

  • Scrape tokenizes the ad body, headline, caption, and link description.
  • It compares those tokens against product title, summary, angle, suggested hooks, category, and destination hostname.
  • High-confidence matches get a visible confidence score and matching reasons directly in Ad Intelligence.

How to run it

  1. Set the environment variables above on the API deployment.
  2. Make sure your category discovery flow has already populated logs/category-discovery-state.json so Winning Ads can expand the live category set automatically.
  3. Run the worker once with node src/winningAdsWorker.js --once to populate the first dataset.
  4. In production, the backend now starts the Winning Ads interval automatically and resyncs every 12 hours by default based on WINNING_ADS_INTERVAL_HOURS.

What Scrape shows after sync

  • Inline video creatives when the actor returns a video URL.
  • CTA and landing-page links when Meta exposes them.
  • AI summary, why-it-works analysis, hook type, visual style, and emotional angle.
  • Matched product title, score, match confidence, and matching signals.
Analytics consent

Scrape uses privacy-light analytics to understand product usage and fix issues. We only load Umami after consent. You can change this later in Cookie settings. See our Cookie Policy and Privacy Policy.