Facebook 广告 api - 无法在广告中添加自定义跟踪规范

facebook ads api - can't add custom tracking specs in an ad

我正在使用facebook-python-ads-sdk,我已经关注了官网:

https://developers.facebook.com/docs/marketing-api/tracking-specs#examples

与:

像素追踪 您可以通过在广告的 tracking_specs 字段中指定跟踪像素来跟踪广告中不同像素的效果。假设您定义:

tracking_specs="[
  {'action.type':'offsite_conversion','fb_pixel':1},
  {'action.type':'offsite_conversion','fb_pixel':2},
  {'action.type':'offsite_conversion','fb_pixel':3}
]"

问题是当我将它添加到广告中时,它向我显示错误

"error": {
        "code": 100, 
        "is_transient": false, 
        "error_subcode": 1634019, 
        "error_user_msg": "Please check that a valid and non-empty object id is passed in.", 
        "error_user_title": "The id of the object (post, page, etc) passed in is invalid.", 
        "message": "Invalid parameter", 
        "type": "FacebookApiException", 
        "fbtrace_id": "HhCZrs9+8GH"
      }

我的代码:

ad = Ad(parent_id=account_id)
ad[Ad.Field.name] = ad_name
ad[Ad.Field.adset_id] = adset_id
ad[Ad.Field.tracking_specs] = {'action.type': 'offsite_conversion', 'fb_pixel': 6029740175958}

当我删除 tracking_specs 时,它起作用了 fine.And 我已将像素添加到广告集,它对我来说也很好用。

ad_set[AdSet.Field.promoted_object] = {'pixel_id': 6015522072958}

所以像素 ID 是正确的。

我哪里做错了?感谢您的回答。

该死,我向 https://graph.facebook.com/2.5/{Ad_ID} 发出了 GET 请求, 我之前在广告中添加了跟踪规范。

然后,我得到:

"tracking_specs": [
    {
      "action.type": [
        "offsite_conversion"
      ],
      "offsite_pixel": [
        "6015521805358",
        "6015522072958",
        "6029740098558",
        "6029740175958"
      ]
    },
    {
      "action.type": [
        "post_engagement"
      ],
      "page": [
        "380039845369159"
      ],
      "post": [
        "1062663363773467"
      ]
    }
  ],

你注意到区别了吗?

就是offsite_pixel字段。 在上面的例子中,它是fb_pixel。 ¯\(°_°)/¯