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.ads.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 siteresult = client.tracking_tags.create_tracking_tag(
account_id="ACCOUNT_ID",
ad_account_id="act_1234567890",
name="My Website Pixel",
)
print(result.tag.id) # new pixel ID
print(result.tag.code) # the install snippetcurl -X POST "https://zernio.com/api/v1/accounts/ACCOUNT_ID/tracking-tags" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"adAccountId":"act_1234567890","name":"My Website Pixel"}'The 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 },
});# Every pixel the connected ad account can see (pass ad_account_id to scope to one)
listing = client.tracking_tags.list_tracking_tags(account_id="ACCOUNT_ID")
# One pixel — includes its install code, last_fired_time, owner_business_id
one = client.tracking_tags.get_tracking_tag(
account_id="ACCOUNT_ID", tag_id="1729525464415281"
)
# Rename, or toggle Advanced Matching / first-party cookies / data-use
client.tracking_tags.update_tracking_tag(
account_id="ACCOUNT_ID",
tag_id="1729525464415281",
name="Website Pixel (renamed)",
enable_automatic_matching=True,
)curl "https://zernio.com/api/v1/accounts/ACCOUNT_ID/tracking-tags" \
-H "Authorization: Bearer YOUR_API_KEY"
curl "https://zernio.com/api/v1/accounts/ACCOUNT_ID/tracking-tags/1729525464415281" \
-H "Authorization: Bearer YOUR_API_KEY"
curl -X PATCH "https://zernio.com/api/v1/accounts/ACCOUNT_ID/tracking-tags/1729525464415281" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"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' },
});client.tracking_tags.add_tracking_tag_shared_account(
account_id="ACCOUNT_ID",
tag_id="1729525464415281",
ad_account_id="act_9876543210",
)curl -X POST "https://zernio.com/api/v1/accounts/ACCOUNT_ID/tracking-tags/1729525464415281/shared-accounts" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"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.
- One pixel per ad account on create.
POST .../tracking-tagsreturns a 400 (A pixel already exists for this account) if that ad account already has one. A Business Manager can own many pixels, just not two on the same ad account via this call. - 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.