tmarois / laravel-ads-sdk

PHP SDK for Google Ads, Bing Ads, and Facebook Ads API for Laravel
MIT License
113 stars 46 forks source link

Facebook Reports: Need to specify proper level param #33

Closed maxSupermoney closed 3 years ago

maxSupermoney commented 3 years ago

In the facebook-implement branch, src/Services/FacebookAds/Reports.php, for functions getCampaignReport and getAdGroupReport, it looks like you need to specify the proper $params['level'], either 'campaign' or 'adset'. It's currently using 'account', and using that I can't get campaign_id or campaign_name when trying to get a campaign report. It seems to work if it's set to 'campaign'. I assume adGroup/adset is the same, but I haven't tested that yet.

timothymarois commented 3 years ago

Ok thanks, yeah I think I ran that in for testing, I'll add that as a custom option, when testing on getCampaignReport and using account level, I was able to get campaign_id and name back, I'm curious to know what params you were using, nonetheless, I'll make it custom, very odd why they are being so specific. New release will be made for Friday, let me know if you find anything else

maxSupermoney commented 3 years ago

I wonder if it's due to v11 vs v10? This is how I was grabbing the report

$report = $facebookAds->reports($startDate, $endDate)->setParams(['time_increment' => 1])->setFields([
        AdsInsightsFields::ACCOUNT_ID,
        AdsInsightsFields::ACCOUNT_NAME,
        AdsInsightsFields::CAMPAIGN_ID,
        AdsInsightsFields::CAMPAIGN_NAME,
        AdsInsightsFields::DATE_START,
        AdsInsightsFields::DATE_STOP,
        AdsInsightsFields::IMPRESSIONS,
        AdsInsightsFields::CLICKS,
        AdsInsightsFields::CTR,
        AdsInsightsFields::CONVERSIONS,
        AdsInsightsFields::CONVERSION_VALUES,
        AdsInsightsFields::CPC, // average
        AdsInsightsFields::COST_PER_CONVERSION,
        AdsInsightsFields::CPM, // average
        AdsInsightsFields::COST_PER_ACTION_TYPE,
        AdsInsightsFields::ACTIONS,
        AdsInsightsFields::ACTION_VALUES,
        AdsInsightsFields::SPEND
     ])->getCampaignReport();
timothymarois commented 3 years ago

Ok, just made an update that moves level param to the default params so that you can override level as a param itself now. and by default for account, campaign and adset it will use the actual level for those reports. Going to close this for now, I'm on discord if you can and we can iron out these details, hope this helps.