在targeting_spec上按性别过滤

时间:2018-11-07 08:46:01

标签: facebook facebook-marketing-api

如何在Facebook Marketing API定位规范中设置性别?

我尝试设置性别,但是我得到的性别不是有效的目标规范字段错误。

targeting_spec = {"geo_locations":
                {
                    "location_types": ["recent"],
                    "custom_locations": [
                        {
                            "latitude": 14.5764,
                            "longitude": 121.0851,
                            "radius": 17
                        }
                    ]
                },
                "age_min": 18,
                "age_max": 35,
                "gender": "male", // Setting gender, doesn't work
                "flexible_spec": [
                    {
                        "interests": [
                            {"id": "6002998074973", "name": "BTS"}
                        ]
                    },
                    {
                        "interests": [
                            {"id": "6005882720291", "name": "Data Science"}
                        ]
                    }
                ]
             }

2 个答案:

答案 0 :(得分:0)

找到了!应该是性别

值是:

gender: [0] # All
gender: [1] # Men
gender: [2] # Women

答案 1 :(得分:0)

来自https://developers.facebook.com/docs/marketing-api/buying-api/targeting/

  

性别:数组

     
      
  • 1 =男性
  •   
  • 2 =女性。
  •   
  • 默认为全部。
  •   

例如:

targeting: {
  genders: [1]
  ...