2017-06-02 164 views
0

我目前使用Facebook SDK廣告的Python SDK,主要用於在廣告級自動生成基於效果的指標(例如展示次數,金額支出等)按月。根據documentation,似乎amount_spent僅在AdAccount級別,而我正在查找的大多數指標都不可用。Facebook廣告API - 創建與廣告管理器相似的效果報告

是否可以使用此API創建Ads Manager報告?如果我沒有弄錯,它應該是facebookads圖書館。

回答

0

我認爲你要找的是insights。例如:

adcampaign = AdCampaign('<AD_CAMPAIGN_GROUP_ID>') 
ads = adcampaign.get_ads(...) 

for ad in ads: 
    insights = ad.get_insights(fields=['impressions', 'spend', ...]) 

我不使用此API或有權訪問它,所以我無法測試它。這段代碼是從查看文檔和源代碼。請讓我知道這可不可以幫你。

相關鏈接:

0

這是我目前用來從Facebook營銷api中獲取洞察數據的代碼。如果這是你正在尋找的東西。只需將您的表放置在foreach循環中,並在css文件中更改一些顏色,就可以獲得與Facebook廣告管理器類似的內容。

$account = new AdAccount('act_xxxxxxxxxxxxx'); 

    $params = array(
     'time_range' => array(
     'since' => (new \DateTime($beginDate))->format('Y-m-d'), 
     'until' => (new \DateTime($lastDate))->format('Y-m-d'), 
    ), 

     'level' => 'ad', 
     'limit' => '15' 
    ); 

$fields = array(
    AdsInsightsFields::CAMPAIGN_NAME, 
    AdsInsightsFields::CAMPAIGN_ID, 
    AdsInsightsFields::IMPRESSIONS, 
    AdsInsightsFields::UNIQUE_CLICKS, 
    AdsInsightsFields::REACH, 
    AdsInsightsFields::SPEND, 
    AdsInsightsFields::TOTAL_ACTIONS, 
); 

$insights = $account->getInsights($fields, $params); 

foreach($insights as $i){ 
$i->campaign_id; 
etc. 
etc. 
} 
+0

感謝您的回覆。我最終找到了我正在尋找的解決方案。正如Paco H.早些時候的迴應:我不得不使用get_insights()函數來獲得我需要的。 – wchang

+0

沒問題。很高興你想出來了。 –