Meta Ads Collector Skill

## Purpose

3,891 stars

Best use case

Meta Ads Collector Skill is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

## Purpose

Teams using Meta Ads Collector Skill should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/meta-ads-collector-adarsh/SKILL.md --create-dirs "https://raw.githubusercontent.com/openclaw/skills/main/skills/adarshvmore/meta-ads-collector-adarsh/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/meta-ads-collector-adarsh/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How Meta Ads Collector Skill Compares

Feature / AgentMeta Ads Collector SkillStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

## Purpose

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# Meta Ads Collector Skill

## Purpose
Scans the Meta Ad Library API to find active advertisements for a given brand. Extracts the number of active ads, ad formats used, ad types, and the longest-running ad duration. This collector feeds into the Marketing Audit Pipeline to populate the Paid Ads Strategy section of the final report.

## Input Schema
```typescript
// Function signature
collectMetaAds(brandName: string, domain?: string): Promise<MetaAdsData>

// brandName: The brand name to search for in the Ad Library (e.g. "Gymshark")
// domain: Optional domain to refine search (e.g. "gymshark.com"). Used to filter
// results and improve relevance when the brand name is ambiguous.
```

## Output Schema
```typescript
interface MetaAdsData {
 activeAds: number; // Total count of currently active ads
 formatsUsed: string[]; // e.g. ["image", "video", "carousel"]
 longestRunningAdDays: number; // Days the longest-running active ad has been live
 adTypes: string[]; // e.g. ["POLITICAL_AND_ISSUE_ADS", "HOUSING_ADS", "OTHER"]
 estimatedSpend?: string; // e.g. "$10,000 - $50,000" (if available from API)
 error?: string; // Present only when collector fails
}
```

## API Dependencies
- **API Name:** Meta Ad Library API
- **Endpoint:** `https://graph.facebook.com/v19.0/ads_archive`
- **Auth:** `META_ACCESS_TOKEN` environment variable (requires a Facebook App with Ad Library API access)
- **Additional env vars:** `META_APP_ID`, `META_APP_SECRET` (used for token generation if needed)
- **Cost estimate:** Free (no per-request charge)
- **Rate limits:** Subject to Meta's standard Graph API rate limits (~200 calls/hour)

## Implementation Pattern

### Data Flow
1. Receive `brandName` and optional `domain` from the pipeline
2. Call `metaAdsService.getMetaAds(brandName, domain)` which queries the Ad Library API
3. Process the returned ads array to extract metrics
4. Map processed data to the `MetaAdsData` interface

### API Query Parameters
```typescript
{
 access_token: process.env.META_ACCESS_TOKEN,
 search_terms: brandName,
 ad_reached_countries: "['US']", // Default to US; can be expanded
 ad_active_status: "ACTIVE", // Only fetch currently active ads
 ad_type: "ALL", // Include all ad types
 fields: "id,ad_creation_time,ad_creative_bodies,ad_creative_link_captions,ad_creative_link_titles,ad_delivery_start_time,ad_snapshot_url,page_name",
 limit: 100 // Max results per page
}
```

### Metrics Calculation

**Active Ads Count:**
- Count the total number of ads returned from the API response

**Formats Detection:**
- Analyze `ad_snapshot_url` or creative fields to classify format
- Categories: `"image"`, `"video"`, `"carousel"`, `"dynamic"`, `"collection"`
- Deduplicate into a unique list

**Longest Running Ad:**
```typescript
const now = new Date();
const longestRunningAdDays = Math.max(
 ...ads.map(ad => {
 const startDate = new Date(ad.ad_delivery_start_time);
 return Math.floor((now.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24));
 })
);
```

**Ad Types:**
- Extract unique `ad_type` values from the response
- Common types: `"POLITICAL_AND_ISSUE_ADS"`, `"HOUSING_ADS"`, `"CREDIT_ADS"`, `"EMPLOYMENT_ADS"`, general/uncategorized

**Estimated Spend:**
- Only available for political/issue ads (Meta requirement)
- For other ad types, this field will be `undefined`
- If available, format as a range string: `"$10,000 - $50,000"`

### Domain Filtering
When `domain` is provided:
- Filter results to only include ads where the creative body, link caption, or link title references the domain
- This improves accuracy for brands with common names

## Error Handling
- Entire function wrapped in `try/catch`
- On failure, return `EMPTY_META_ADS_DATA` with `error` field set:
 ```typescript
 return { ...EMPTY_META_ADS_DATA, error: 'Meta Ads data unavailable: <reason>' };
 ```
- Never throw -- always return a valid `MetaAdsData` object
- Log errors with Winston logger including brandName and error details:
 ```typescript
 logger.error('Meta Ads collector failed', { brandName, domain, err });
 ```
- Common failure scenarios:
 - Access token invalid, expired, or lacking Ad Library permissions
 - Brand name returns zero results (not necessarily an error -- return zeroed data without error flag)
 - Rate limit exceeded (Meta Graph API throttling)
 - Network timeout

## Example Usage
```typescript
import { collectMetaAds } from '../collectors/metaAdsCollector';

// Successful collection
const data = await collectMetaAds('Gymshark', 'gymshark.com');
// Returns:
// {
// activeAds: 47,
// formatsUsed: ["image", "video", "carousel"],
// longestRunningAdDays: 182,
// adTypes: ["OTHER"],
// estimatedSpend: undefined,
// }

// No ads found (not an error)
const noAds = await collectMetaAds('TinyLocalShop');
// Returns:
// {
// activeAds: 0,
// formatsUsed: [],
// longestRunningAdDays: 0,
// adTypes: [],
// }

// Failed collection (graceful degradation)
const failedData = await collectMetaAds('Gymshark');
// Returns:
// {
// activeAds: 0,
// formatsUsed: [],
// longestRunningAdDays: 0,
// adTypes: [],
// error: "Meta Ads data unavailable: Access token expired"
// }
```

## Notes
- The collector depends on `metaAdsService.ts` for the actual API communication. The collector handles only data aggregation and metric calculation.
- Meta Ad Library API requires a Facebook App registered with Ad Library access. The app must be reviewed and approved by Meta for production use.
- The API only returns publicly available ad data. Spend data is only available for political/issue ads as mandated by Meta's transparency policies.
- Zero active ads is a valid result (small or new brands may not run Meta ads) and should be returned without an error flag.
- The `EMPTY_META_ADS_DATA` constant is defined in `src/types/audit.types.ts` and should be imported for fallback returns.
- This collector must never block the pipeline. Even a complete failure returns valid typed data with an error flag.
- Pagination: the Meta API returns a maximum of 100 results per page. For brands with many ads, pagination via the `after` cursor may be needed. For audit purposes, the first page (100 ads) is sufficient.

Related Skills

metacognitive-self-mod

3891
from openclaw/skills

Analyze and improve the improvement process. Use for detecting quality regressions and refining meta-optimization

tianyancha-bidding-collector

3891
from openclaw/skills

天眼查招投标数据查询工具 - 基于浏览器自动化技术批量查询企业招投标/中标公示信息,导出结构化 CSV 报表。支持 macOS 和 Windows 跨平台运行。

meta-ad-spy

3891
from openclaw/skills

Competitive intelligence skill for spying on competitor ads using Meta's Ad Library. Use this skill whenever the user wants to: research competitor Facebook/Instagram ads, analyze ad strategies, extract ad creatives or copy, find how long ads have been running, scout ad spend patterns, monitor industry advertising trends, or build any kind of competitor ad intelligence report. Triggers on phrases like "check competitor ads", "what ads is [brand] running", "spy on ads", "Facebook ad library", "Meta ad library", "scrape ads", "monitor ads", "ad intelligence", "ad research", or any request to analyze advertising strategies on Meta platforms. Always use this skill even if the user just mentions they want to understand what a competitor is doing on Facebook or Instagram.

design-inspiration-collector

3891
from openclaw/skills

多平台设计灵感收集技能。当用户需要设计参考、UI灵感、视觉创意时触发。用户提出设计方向(如"医疗App"、"移动端UI"、"金融Dashboard"等),技能负责:(1) 使用Tavily搜索Behance、Dribbble、Pinterest三个平台的相关内容 (2) 整理内容并附上链接 (3) 生成腾讯文档,文档命名为"关键词+日期时间"格式 (4) 发送文档链接给用户 (5) 推荐其他相关方向(不带链接)。触发词:找灵感、收集灵感、设计参考、UI参考、视觉灵感、设计趋势、Behance、Dribbble、Pinterest。

zhua-metacognition

3891
from openclaw/skills

爪爪元认知系统 —— 思考自己的思考、监控认知过程、优化决策质量。Use when 爪爪需要反思自己的思维过程、优化认知策略、或提升决策质量。

Skill Builder — Meta-Skill for Creating Skills

3891
from openclaw/skills

## Metadata

meta-mcp-wizard

3891
from openclaw/skills

Use the MCPHero Meta-MCP server inside AI clients (Claude Desktop, Cursor, etc.) to create, deploy, and manage MCP servers through the wizard pipeline. Use this skill when the user wants to connect the Meta-MCP server, build MCP servers interactively via MCP tools, or asks about the meta-mcp endpoint at api.mcphero.app.

kb-collector

3891
from openclaw/skills

Knowledge Base Collector - save YouTube, URLs, text to Obsidian with AI summarization. Auto-transcribes videos, fetches pages, supports weekly/monthly digest emails and nightly research.

MetaMask Agent Wallet

3891
from openclaw/skills

Control a sandboxed MetaMask browser extension wallet for autonomous blockchain transactions. Features configurable permission guardrails including spend limits, chain allowlists, protocol restrictions, and approval thresholds. MetaMask-only (other wallets not supported).

meta-research

3891
from openclaw/skills

Autonomous research workflow agent for AI and scientific research. Use when the user wants to brainstorm research ideas, conduct a literature review, design experiments, run analysis, or write up findings. Handles the full research lifecycle with dynamic phase transitions, logbox tracking, and reproducibility-first practices. Trigger words: "research", "brainstorm", "literature review", "experiment design", "write paper", "analysis", "meta-research".

industry-news-collector

3891
from openclaw/skills

行业新闻聚合与热度排序工具。当用户询问XX行业的最新动态时触发,如:"今天有什么XX行业新闻?""总结一下这周的XX行业动态""最近XX行业有什么热点?"。覆盖:新产品发布、行业动态、融资新闻、技术突破、政策变化等。输出中文摘要列表,按热度排序,附带原文链接。

metagenomic-krona-chart

3891
from openclaw/skills

Analyze data with `metagenomic-krona-chart` using a reproducible workflow, explicit validation, and structured outputs for review-ready interpretation.