Guide Codex through instrumenting or extending repositories with OpenAI Ads Measurement Pixel and optional Conversions API (CAPI). Use when adding Ads conversion tracking, browser pixel events, server-side conversion events, event_id deduplication, CAPI secret placeholders, incremental conversion coverage, or validating Ads conversion setup. Applies to local repositories and PR review contexts; prioritize safe, reviewable diffs and never place API keys or secrets in source code or client bundles.
75
92%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Low
Low-risk findings worth noting
Use this skill to add, extend, or review OpenAI Ads conversion instrumentation in an advertiser repository. It supports browser Pixel setup, server-side Conversions API setup, Pixel+CAPI deduplication, and incremental reruns after the app adds new pages or flows, while keeping diffs small and avoiding secret exposure.
Use only public OpenAI Ads documentation and repository-local patterns for implementation choices. If the docs are unavailable or unclear, ask for clarification or leave a documented follow-up instead of relying on undocumented behavior.
Before editing code, identify:
pixel, capi, or pixel+capi.propose patch, apply local patch, or review existing integration.Treat the linked OpenAI Ads docs as the source of truth for exact SDK syntax, endpoint shape, supported events, request fields, and validation rules. When browsing is available, check the current docs before writing concrete calls; if the docs conflict with this skill, follow the docs and mention the conflict in the setup report. When browsing is unavailable, use this skill's references as a fallback. Do not invent SDK functions, event names, request schemas, or endpoint paths.
Primary docs to prefer when available:
https://developers.openai.com/ads/measurement-pixelhttps://developers.openai.com/ads/conversions-apihttps://developers.openai.com/ads/supported-eventsInspect the repository shape.
Confirm the setup plan.
event_id strategy so browser and server events can deduplicate.oppref strategy and a sanitized source_url strategy before editing. Prefer a server-readable raw __oppref cookie value; if unavailable, pass minimal optional conversion context from the browser to an existing server conversion request. For deduped Pixel+CAPI events, make CAPI source_url describe the same browser conversion context as the paired Pixel event when practical. If the browser fires the Pixel event before navigation and the server would otherwise derive a different URL, pass the browser's current sourceUrl to the server and validate it against a trusted request/configured origin before using it. If a configured canonical site origin exists, prefer it for fallback source_url construction while still allowing the request origin as trusted.oppref, source_url, client user_agent, trusted client IP, and documented hashed user identifiers when safely available.validate_only: true is documented for local smoke tests, but committed env templates and runtime defaults should be blank or false unless the user explicitly asks for validation-only behavior.page_viewed, contents_viewed, items_added, checkout_started, order_created, lead_created, registration_completed, appointment_scheduled, subscription_created, and trial_started) and report high-confidence events you will instrument plus supported events you intentionally skip.page_viewed is not instrumented, explicitly say why: too noisy, SPA route semantics unclear, no meaningful landing pages, already covered by an existing helper, or intentionally deferred.Implement the smallest useful patch.
NEXT_PUBLIC_OPENAI_ADS_PIXEL_ID or VITE_OPENAI_ADS_PIXEL_ID are allowed for browser Pixel code, but document that they must contain the same Pixel ID as the server-side Pixel ID when CAPI sends the same event.event_name, event_time_epoch_ms, event_source_url, or event_data.items_added, cover all successful add-to-cart and quantity-increment paths you can confirm; if you only cover a subset, say that clearly in the setup report and offer the missing paths as follow-ups.oaiq("init", { user }) call near that point. Do this for normal web checkout/signup flows unless consent, opt-out, or repository policy prevents it; if skipped, explain why in the setup report. Do not include pixelId again after a successful first init, and do not put Pixel user data in measure calls.Verify locally.
python3 <installed-skill-path>/scripts/verify_capi_secret_not_exposed.py <repo>python3 <installed-skill-path>/scripts/verify_ads_setup.py <repo> --pixel-id <id> --require pixel --require capi--require dedupe --require shared-pixel-id --require oppref --require source-url.Produce a setup report.
oppref strategy, CAPI source_url strategy, browser-provided sourceUrl trust boundary, CAPI user-data strategy, event deduplication strategy, checks run, manual follow-ups, and risks.When rerunning this skill on a repository that may already have OpenAI Ads instrumentation:
event_id generation, oppref and source_url handling, user-data handling, tests, and docs.Use references/measurement-pixel.md for browser Pixel details.
https://bzrcdn.openai.com/sdk/oaiq.min.js, initialize with oaiq("init", { pixelId }), and emit events with oaiq("measure", ...).oppref, source_url, timestamps, or batching metadata; the browser SDK handles those transport details. Add debug: true only for local/test debugging, not as a committed production default.oaiq("init", { user }) again with only documented, normalized fields. For checkout, signup, lead, subscription, or registration flows where the browser has email or location data before or after the confirmed conversion, add this second init unless consent, opt-out, or repository policy prevents it, and report any skip. Preserve the repository's existing consent gates for whether measurement and user-data collection are allowed. Put opt_out on the Pixel event options when measurement is allowed but the event should be opted out of future user-level personalization.page_viewed, contents_viewed, items_added, checkout_started, order_created, lead_created, registration_completed, appointment_scheduled, subscription_created, or trial_started. If uncertain, use the closest documented event or leave an explicit follow-up instead of inventing a name.custom only with a valid, documented custom_event_name.Use references/conversions-api.md for server-side setup details.
event_id in both paths.action_source: "web" and a sanitized HTTP(S) source_url containing only origin plus pathname. Strip query strings and fragments before sending; reject or replace non-HTTP(S) URL schemes with a trusted configured web app URL. For deduped Pixel+CAPI events, prefer a source_url from the same browser conversion context as the paired Pixel event. If accepting a browser-provided sourceUrl, require its origin to match the current request origin or a configured canonical site origin before using it; otherwise fall back to a server-derived URL. When a configured canonical site origin exists, use it as the preferred fallback origin and do not let request service/proxy origins override it. If the final CAPI source_url intentionally differs from the Pixel event's browser page, call that out in the setup report. For non-web server conversions, choose the documented action_source that matches the source (mobile_app, offline, physical_store, phone_call, email, or other) instead of forcing web.oppref as opaque attribution context. Prefer a server-readable __oppref cookie over client-supplied request context; pass the raw value unchanged and do not parse, URL-decode, cookie-decode, generate, transform, or log it.events[].user only for documented fields already available through an approved repository pattern. Never send raw email or raw external IDs. For CAPI-only web conversions, make a best effort to include client user_agent, trusted client IP, and hashed email or external ID when available; these fields are especially important when there is no paired Pixel event.timestamp_ms; do not send stale backfills older than the documented window or future-dated events.opt_out fields when the repository has a relevant user-level personalization opt-out.contents payloads, use top-level data.amount for the event total. For item-level contents[].amount, use the unit price when the repository exposes it; omit item-level amount if only line totals are available or the semantics are unclear.Use references/framework-patterns.md for common locations and pitfalls in Next.js, React/Vite, Remix, Express, Rails, Django, Flask, and monorepos.
Treat these as hints, not rules. The repository's existing conventions win.
Use references/verification-checklist.md for validation steps and references/report-schema.md for the final setup report format.
High-priority failure cases:
source_url.measure instead of init, includes undocumented/raw identity fields, or bypasses the repository's existing consent gates.timestamp_ms is stale, future-dated beyond the documented allowance, or not tied to the actual conversion time.web for non-web/mobile/offline events instead of using an appropriate documented action_source.custom_event_name.oppref context or log oppref alongside raw identifiers.source_url accepts non-HTTP(S) schemes or preserves query strings/fragments.oppref instead of passing the raw opaque value through unchanged.sourceUrl with an untrusted origin instead of falling back to a server-derived URL.source_url.init({ user }) call nor explicitly skipped with a consent/policy reason.source_url without explanation.Ask before proceeding when:
11c74d6
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.