You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Facebook Python SDK创建转化目标广告时遇追踪像素必填错误

解决Facebook广告创建时的"Tracking pixel required"错误

错误提示明确说明:"A tracking pixel is required for ads in a campaign with conversions as its objective.",即当广告系列的目标为「转化(Conversions)」时,必须关联有效的Facebook追踪像素才能创建广告。

解决步骤

  1. 确认追踪像素已创建并关联到广告账户
    确保你已在Facebook Business Manager中创建了像素,并且该像素已绑定到当前使用的广告账户(act_xxx)。

  2. 给广告组(AdSet)添加追踪像素配置
    最规范的方式是在广告组层级设置追踪像素,同一广告组下的所有广告会继承该配置。你可以通过更新已有AdSet或在创建AdSet时添加参数:

    def update_adset_with_pixel(adset_id, pixel_id, access_token):
        initialize_facebook_api(app_id, app_secret, access_token)
        adset = AdSet(adset_id)
        params = {
            'tracking_specs': [
                {
                    'action.type': ['offsite_conversion'],
                    'fb_pixel': {'id': pixel_id}
                }
            ]
        }
        return adset.update(fields=[], params=params)
    
  3. (可选)在广告层级直接指定像素
    若需给单个广告单独配置像素(优先推荐广告组层级配置),可修改你的schedule_ad函数,在params中添加tracking_specs:

    def schedule_ad(ad_account_id, adset_id, creative_id, access_token, title, pixel_id):
        initialize_facebook_api(app_id, app_secret, access_token)
        account = AdAccount(ad_account_id)
        fields = []
        params = {
            'name': title + '_ad',
            'adset_id': adset_id,
            'creative': {'creative_id': creative_id},
            'status': 'PAUSED',
            'tracking_specs': [
                {
                    'action.type': ['offsite_conversion'],
                    'fb_pixel': {'id': pixel_id}
                }
            ]
        }
        return account.create_ad(fields=fields, params=params)
    

注意事项

  • 确保pixel_id是你的有效像素ID(格式如1234567890)
  • 仅当广告系列目标为「转化」时需要此配置,其他目标无需强制设置

内容的提问来源于stack exchange,提问作者Tushar Raina

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 10:03:12