如何通过API获取Facebook跟踪网址参数

时间:2017-03-30 01:08:35

标签: facebook facebook-graph-api facebook-marketing-api

当我在business.facebook.com上编辑广告时,我可以看到"跟踪"有一个名为" URL参数"的字段的部分。

enter image description here

我正在尝试使用(图表或营销)API获取该字段的值,但在阅读了很多内容后,我无法找到实现该目标的方法。

有人知道这是否可能?

3 个答案:

答案 0 :(得分:2)

请参阅“广告素材”对象,“网址标记”字段。

此处有更多信息:https://developers.facebook.com/docs/marketing-api/reference/ad-creative

哎呀,这似乎只是为了写作。看起来这个字段在读取对象时总是空的。 :(

答案 1 :(得分:0)

免责声明:我对中间图API的使用还很陌生,但这是我到目前为止所想到的。

python页面似乎在一个很好的长列表中给出了所有字段,因此我将这些字段复制并粘贴到API URL中:

  

actor_id,actor_image_hash,actor_name,adlabels,applink_treatment,   body,call_to_action_type,dynamic_ad_voice,filename,   follow_redirect,id,image_crops,image_file,image_hash,image_url,   instagram_actor_id,instagram_permalink_url,link_deep_link_url,   link_url,name,object_id,object_store_url,object_story_id,   object_story_spec,object_type,object_url,place_page_set_id,   preview_url,product_set_id,template_url,thumbnail_url,title,   url_tag

这样的事情(空间还可以):

  

/v2.12/act_XXXXXXX/adcreatives/?fields=actor_id,actor_image_hash,   actor_name,adlabels,applink_treatment,body,call_to_action_type,   dynamic_ad_voice,filename,follow_redirect,id,image_crops,   image_file,image_hash,image_url,instagram_actor_id,   instagram_permalink_url,link_deep_link_url,link_url,name,   object_id,object_store_url,object_story_id,object_story_spec,   object_type,object_url,place_page_set_id,preview_url,   product_set_id,template_url,thumbnail_url,title,   url_tag&安培;限= 100安培; effective_status = [ “ACTIVE”]

这给了我完整的树:

{
  "data": [
    {
      "body": "XXXXXXX",
      "call_to_action_type": "LEARN_MORE",
      "id": "XXXXXXX",
      "image_hash": "XXXXXXX",
      "image_url": "XXXXXXX",
      "instagram_actor_id": "XXXXXXX",
      "instagram_permalink_url": "XXXXXXX",
      "name": "#‏XXXXXXX",
      "object_story_spec": {
        "page_id": "XXXXXXX",
        "instagram_actor_id": "XXXXXXX",
        "video_data": {
          "video_id": "XXXXXXX",
          "title": "XXXXXXX",
          "message": "XXXXXXX",
          "link_description": "XXXXXXX",
          "call_to_action": {
            "type": "LEARN_MORE",
            "value": {
              "link_caption": "EXAMPLE.COM",
              "link": "https://example.com/your-page",
              "link_format": "VIDEO_LPP"
            }
          },
          "image_hash": "XXXXXXX"
        }
      },
      "object_type": "VIDEO",
      "thumbnail_url": "XXXXXXX",
      "title": "XXXXXXX"
    },

所以现在我知道它可以被退回,而且绝对不是只写的。

在玩了一些之后,我发现它是单个字段object_story_spec,它返回所有这一切:

"data": [
    {
      "object_story_spec": {
        "page_id": "XXXXXXX",
        "instagram_actor_id": "XXXXXXX",
        "video_data": {
          "video_id": "XXXXXXX",
          "title": "XXXXXXX!",
          "message": "XXXXXXX",
          "link_description": "XXXXXXX",
          "call_to_action": {
            "type": "LEARN_MORE",
            "value": {
              "link_caption": "EXAMPLE.COM",
              "link": "https://EXAMPLE.COM/YOUR-WEBSITE-LINK",
              "link_format": "VIDEO_LPP"
            }
          },
          "image_hash": "XXXXXXX"
        }
      },
      "id": "XXXXXXX"
    },

因此,像linkobject_id这样的字段可能不适用于我使用的广告类型(主要是带有网站链接的视频) - 或者它们可能仅用于制作广告 - 但我我真的不在乎,因为现在我有了我需要的数据。

我正在使用https://developers.facebook.com/tools/explorer来实现此目标

答案 2 :(得分:0)

您可以通过Graph API在广告素材一级的“ url_tags”下找到此信息。

官方文档:https://developers.facebook.com/docs/marketing-api/reference/ad-creative/#fields