How can i use multiple client accounts to get report

218 views
Skip to first unread message

vananpp...@gmail.com

unread,
Dec 8, 2017, 4:47:35 AM12/8/17
to AdWords API Forum
Hi Team,
     I need to get report for multiple client accounts under one manager account. I dont know how to use this feature. my client id and other configuration are configured in 'adsapi_php.ini' file.

       $selector         = new Selector();
        $FromDate         = ($fromdate) ? $fromdate : date('Ymd');
        $ToDate           = ($todate) ? $todate : date('Ymd');
        $selector->setDateRange(new DateRange($FromDate, $ToDate));
        $selector->setFields(['CampaignName', 'AdGroupName', 'Criteria', 'QualityScore', 'Impressions', 'Clicks', 'Ctr', 'AverageCpc', 'Cost', 'AveragePosition', 'Conversions']); //, 'CostPerConversion', 'ConversionRate', 'AllConversions', 'ViewThroughConversions'
//        $selector->setPredicates([new Predicate('Status', PredicateOperator::NOT_IN, ['PAUSED'])]);
        $reportDefinition = new ReportDefinition();
        $reportDefinition->setSelector($selector);
        $reportDefinition->setReportName(
                'Criteria performance report #' . uniqid());
        $reportDefinition->setDateRangeType(
                ReportDefinitionDateRangeType::CUSTOM_DATE);
        $reportDefinition->setReportType(ReportDefinitionReportType:: KEYWORDS_PERFORMANCE_REPORT);
//        $reportDefinition->setReportType(ReportDefinitionReportType:: KEYWORDLESS_QUERY_REPORT);
        $reportDefinition->setDownloadFormat(DownloadFormat::CSV);

        // Download report.
        $reportDownloader       = new ReportDownloader($session);
        // Optional: If you need to adjust report settings just for this one
        // request, you can create and supply the settings override here. Otherwise,
        // default values from the configuration file (adsapi_php.ini) are used.
        $reportSettingsOverride = (new ReportSettingsBuilder())
                ->includeZeroImpressions(false)
                ->build();
        $reportDownloadResult   = $reportDownloader->downloadReport(
                $reportDefinition, $reportSettingsOverride);
        $reportDownloadResult->saveToFile($filePath);

Bharani Cherukuri (AdWords API Team)

unread,
Dec 8, 2017, 11:19:04 AM12/8/17
to AdWords API Forum
Hello, 

You could use Parallel report download that allows users to generate reports for all the accounts under an MCC in multiple parallel threads. This report should be run against an AdWords manager account. All you have to do is specify the manager account customer ID as clientCustomer ID in the adsapi_php.ini file. This will retrieve all the accounts that are in the hierarchy and generate the report stats. You could refer to the Parallel report download code sample in PHP here.

Regards,
Bharani, AdWords API Team
Reply all
Reply to author
Forward
0 new messages