如何将广告图片与广告见解联系起来?(Facebook广告Python SDK)
我正在尝试将广告洞察与广告图像URL连接起来,以便在仪表板中显示广告及其性能。因此,我需要将“广告洞察”数据集与“广告图像”数据集合并。我知道如何分别提取它们,但不知道哪一列可以用作键ID列来合并这两个数据集。(请注意,通过API提供的字段比我在下面使用的字段多得多。) 获取见解:如何将广告图片与广告见解联系起来?(Facebook广告Python SDK),python,facebook,facebook-graph-api,facebook-ads-api,facebook-marketing-api,Python,Facebook,Facebook Graph Api,Facebook Ads Api,Facebook Marketing Api,我正在尝试将广告洞察与广告图像URL连接起来,以便在仪表板中显示广告及其性能。因此,我需要将“广告洞察”数据集与“广告图像”数据集合并。我知道如何分别提取它们,但不知道哪一列可以用作键ID列来合并这两个数据集。(请注意,通过API提供的字段比我在下面使用的字段多得多。) 获取见解: insights = account.get_insights(fields=[ AdsInsights.Field.date_start, AdsInsights.Field.ad_id,
insights = account.get_insights(fields=[
AdsInsights.Field.date_start,
AdsInsights.Field.ad_id,
AdsInsights.Field.ad_name,
AdsInsights.Field.impressions,
AdsInsights.Field.clicks,
AdsInsights.Field.inline_post_engagement,
AdsInsights.Field.video_10_sec_watched_actions,
# AdsInsights.Field.canvas_avg_view_time,
], params={
'level': AdsInsights.Level.ad,
'breakdowns': 'publisher_platform',
'time_range': {'since': str(datetime.date(2017,1,15)), 'until': str(datetime.date(2017,1,21))},
})
Ads洞察输出示例:
<AdsInsights> {
"ad_id": "6074251934453",
"ad_name": "Post 185|Campaign|Video|:15 Video|Chloe Ombre Legging|Womens|11.11|Gap|Holiday|Marcom|GapFit|On-figure",
"clicks": "80",
"date_start": "2017-01-15",
"date_stop": "2017-01-21",
"impressions": "29898",
"inline_post_engagement": "65",
"publisher_platform": "instagram",
"video_10_sec_watched_actions": [
{
"action_type": "video_view",
"value": "2342"
}
]
}
<AdImage> {
"account_id": "104181146376574",
"created_time": "2017-03-08T10:45:57-0800",
"creatives": [
"6079059384653",
"6079059384853",
"6079059387253"
],
"id": "104181146376574:d2d60f26e67d99e6869c9b8444a3b30c",
"permalink_url": "https://www.facebook.com/ads/image/?d=AQIY0GjCTF9UUMExzqq2QAI3hFKgmObAyivAwfb346WgnzAIiysmGLjU_msd1pJcVxcr4zawWXHsiRviQjrW50lqTXxq3to6CQIQFLptp9DZ9Kanqx0tmFqoIB1_37PLqjGo7cK1bt6G2YxaL29ihdge"
}
广告图像输出示例:
<AdsInsights> {
"ad_id": "6074251934453",
"ad_name": "Post 185|Campaign|Video|:15 Video|Chloe Ombre Legging|Womens|11.11|Gap|Holiday|Marcom|GapFit|On-figure",
"clicks": "80",
"date_start": "2017-01-15",
"date_stop": "2017-01-21",
"impressions": "29898",
"inline_post_engagement": "65",
"publisher_platform": "instagram",
"video_10_sec_watched_actions": [
{
"action_type": "video_view",
"value": "2342"
}
]
}
<AdImage> {
"account_id": "104181146376574",
"created_time": "2017-03-08T10:45:57-0800",
"creatives": [
"6079059384653",
"6079059384853",
"6079059387253"
],
"id": "104181146376574:d2d60f26e67d99e6869c9b8444a3b30c",
"permalink_url": "https://www.facebook.com/ads/image/?d=AQIY0GjCTF9UUMExzqq2QAI3hFKgmObAyivAwfb346WgnzAIiysmGLjU_msd1pJcVxcr4zawWXHsiRviQjrW50lqTXxq3to6CQIQFLptp9DZ9Kanqx0tmFqoIB1_37PLqjGo7cK1bt6G2YxaL29ihdge"
}
{
“账户id”:“104181146376574”,
“创建时间”:“2017-03-08T10:45:57-0800”,
“创意人士”:[
"6079059384653",
"6079059384853",
"6079059387253"
],
“id”:“104181146376574:d2d60f26e67d99e6869c9b8444a3b30c”,
“永久链接url”:https://www.facebook.com/ads/image/?d=AQIY0GjCTF9UUMExzqq2QAI3hFKgmObAyivAwfb346WgnzAIiysmGLjU_msd1pJcVxcr4zawWXHsiRviQjrW50lqTXxq3to6CQIQFLptp9DZ9Kanqx0tmFqoIB1_37PLqjGo7cK1bt6G2YxaL29ihdge"
}
“ad_id”和“creatives”看起来很相似,但在尝试合并它们之后没有匹配
以前有人有过处理这个问题的经验吗?任何意见/想法都将不胜感激 广告图片应该被认为更像是一个你以后可以使用的内容“库”,不要试图将见解与此关联起来,因为可能有0、1或更多的广告使用特定的图片,或者广告不使用此库中的图片 用于您的目的的数据模型可能应该是广告集->广告->广告创意
广告创意包含正在推广的内容的详细信息,通常是页面上的一篇文章,该文章有一个“图像”字段,您可以通过以下方式进行宣传:
ad\u id/insights
ad_id?fields=creative
creative\u id?fields=image\u url
我希望这有帮助 感谢大家的回答;你给我指明了正确的方向。以下是我对自己问题的解决方案,到目前为止效果很好:
# get insights
insights = account.get_insights(fields=[
AdsInsights.Field.date_start,
AdsInsights.Field.ad_id,
AdsInsights.Field.ad_name,
AdsInsights.Field.impressions
], params={
'level': AdsInsights.Level.ad,
'time_range': {'since': str(datetime.date(2017, 3, 31)), 'until': str(datetime.date(2017, 3, 31))}
'time_increment': 1
})
# get a list of ad ids
insights_ids = [insight['ad_id'] for insight in insights]
url_list = []
count = 0
for ad_id in insights_ids:
ad = Ad(fbid=ad_id)
# get creative by ad_id
adcreatives = ad.get_ad_creatives(fields=[
AdCreative.Field.thumbnail_url,
AdCreative.Field.body
])
count += 1
print count
url_dict = {'ad_id': ad_id,
'thumbnail_url': adcreatives[0]['thumbnail_url']
}
url_list.append(url_dict)
time.sleep(2) # will likely hit rate limit when set to 1 sec
希望这能帮助遇到同样问题的人 如果你是根据你知道在特定广告中使用的特定图像进行跟踪,你也可以在自己的应用程序中跟踪该图像->广告链接感谢你澄清了广告图像和广告创意之间的差异;我被两者的不同目的弄糊涂了。现在它更有意义了。