通过FacebookBusiness SDK的Instagram广告见解

时间:2018-06-20 17:17:02

标签: python facebook-graph-api facebook-ads-api

我正在尝试获取有关我公司的instagram广告系列的广告见解。我已经成功地提取了Facebook广告系列的统计信息。现在,我必须知道instagram广告系列对每项业务的影响。是否有人对此有任何见识?我已经引用源代码好几天了,但似乎无法学习如何做到这一点。

session = FacebookSession(
        app_id,
        app_secret,
        access_token,
    )
    api = FacebookAdsApi(session)
    FacebookAdsApi.set_default_api(api)
    campaign = AdCampaign(campaign_id)
    #grab a list of instagram ad campaigns
    # instagram_campaign = AdAccount(instagram_account_id)
    # instagram_campaign.get_insights(<fields,ect>)
    insights = []
    instagram_accounts = []
    i=0
    my_ads = []
    while(i<7):
        string_start_time = str(start_time)
        string_end_time = str(end_time)
        params = {
            'time_range': {
                'since': string_start_time,
                'until': string_end_time,
                },
            'fields': [
                #AdsInsights.Field.impressions,
                AdsInsights.Field.reach,
                AdsInsights.Field.unique_clicks,
                AdsInsights.Field.spend,
                AdsInsights.Field.impressions,
                AdsInsights.Field.cpm,
                AdsInsights.Field.ad_id,
                AdsInsights.Field.campaign_name,
                #AdsInsights.Field.cost_per_unique_outbound_click
                #AdsInsights.Field.spend
                ],
            #'breakdowns': [
            #    AdsInsights.Breakdowns.age
            #]
                }
        insights.append(campaign.get_insights(params=params))
        #instagram_accounts.append(campaign.get_instagram_accounts(params=params))
        i+=1
        start_time += datetime.timedelta(days=1)
        end_time += datetime.timedelta(days=1)

0 个答案:

没有答案