Meta Pixels
Create and manage Meta Pixels
Meta Pixels
A Meta Pixel is the measurement primitive you install on a website, send events to, and target ads against. Zernio exposes it under the platform-neutral tracking tags API — on Meta, kind is pixel. Uses the Meta Ads account you already connected; no extra OAuth, no business_management permission. The accountId is the Meta ads SocialAccount (the one the Ads add-on connect flow creates), not a Facebook/Instagram posting account; get your act_... ad account IDs from zernio.adaccounts.listAdAccounts().
Create a pixel
const { data } = await zernio.trackingtags.createTrackingTag({
path: { accountId: 'ACCOUNT_ID' },
body: { adAccountId: 'act_1234567890', name: 'My Website Pixel' },
});
console.log(data.tag.id); // new pixel ID — use it in promotedObject.pixelId, audiences, CAPI
console.log(data.tag.code); // the base-code snippet to install on the siteThe response is the new tag, including code — the base-code snippet to drop on the site. Creating a pixel doesn't install it: install code, or skip the snippet entirely and send events server-side via the Conversions API (a pixel works as a CAPI destination immediately). installed is derived from lastFiredTime (null = it has never fired).
List, fetch, and rename pixels
// Every pixel the connected ad account can see (pass query.adAccountId to scope to one)
const { data: list } = await zernio.trackingtags.listTrackingTags({
path: { accountId: 'ACCOUNT_ID' },
});
// One pixel — includes its install code, lastFiredTime, ownerBusinessId
const { data: one } = await zernio.trackingtags.getTrackingTag({
path: { accountId: 'ACCOUNT_ID', tagId: '1729525464415281' },
});
// Rename, or toggle Advanced Matching / first-party cookies / data-use
await zernio.trackingtags.updateTrackingTag({
path: { accountId: 'ACCOUNT_ID', tagId: '1729525464415281' },
body: { name: 'Website Pixel (renamed)', enableAutomaticMatching: true },
});Share a pixel with another ad account
By default a pixel only works in the ad account it was created on. Share it with others so their campaigns and audiences can use it (listTrackingTagSharedAccounts and removeTrackingTagSharedAccount round out the set):
await zernio.trackingtags.addTrackingTagSharedAccount({
path: { accountId: 'ACCOUNT_ID', tagId: '1729525464415281' },
body: { adAccountId: 'act_9876543210' },
});For aggregated event counts, call zernio.trackingtags.getTrackingTagStats(...) — aggregation is event by default; also host, url, device_type, and more.
Things to know about Meta Pixels:
- Not idempotent. Each create call makes a new pixel — don't retry blindly on timeout.
- Create is not idempotent. Every
POST .../tracking-tagscall creates a new pixel, so never auto-retry it; on a502confirm withGET .../tracking-tagsbefore retrying. A400means an invalidadAccountId, an ad account outside a Business Manager, or the per-business pixel cap. - No delete. Meta has no API to delete a pixel. To stop using one, unshare it (
DELETE .../shared-accounts) or disable it in Events Manager. - Personal ad accounts can't share. A pixel created on an ad account that isn't owned by a Business Manager comes back with
ownerBusinessId: nulland can't be shared with other ad accounts (Meta rejects the share). Claim the ad account into a Business Manager first. - Not exposed (needs
business_management): sharing a pixel with a partner/agency business, and assigning system users to a pixel.