is AWQL really slow?

64 views
Skip to first unread message

Albert Paolo Rogelio

unread,
Sep 20, 2018, 6:12:49 AM9/20/18
to AdWords API and Google Ads API Forum
Hi I using AWQL to retrieve Account performance of all accounts in a mcc account but it is really slow. im just getting 16 accounts and it will consume up to 35seconds it is really bad. is there any way to speed it up? i mean it is deployed in cloud server so it means it should be fast. im confused it is it just the google api which is slow or my way in retrieving data? here is my code: 

$adWordsServices = new AdWordsServices();
$managedCustomerService = $adWordsServices->get(
$session,
ManagedCustomerService::class
);

$selector = new Selector();
$selector->setFields(['CustomerId', 'Name']);
$selector->setOrdering([new OrderBy('Name', SortOrder::ASCENDING)]);
$selector->setPaging(new Paging(0, 500));
$selector->setPredicates([new Predicate('CustomerId',PredicateOperator::NOT_EQUALS,[$managerId])]);

$clients = $managedCustomerService->get($selector);
foreach($clients->getEntries() as $num => $client)
{
// if($client->getCanManageClients() != null)
// if($num == 5)
// break;

$selector = new Selector();
$selector->setFields( ['AccountDescriptiveName','Clicks','Impressions','Ctr','Conversions','ConversionRate','Cost','AveragePosition','AverageCpc','Date'] );

$reportDefinition = new ReportDefinition();
$reportDefinition->setSelector($selector);
$reportDefinition->setReportName(
'ACCOUNT_PERFORMANCE_REPORT'
);
$reportDefinition->setDateRangeType(
ReportDefinitionDateRangeType::ALL_TIME
);
$reportDefinition->setReportType(
ReportDefinitionReportType::ACCOUNT_PERFORMANCE_REPORT
);
$reportDefinition->setDownloadFormat(DownloadFormat::CSV);
$clientSession = (new AdWordsSessionBuilder())
->withDeveloperToken(MY_DEVELOPER_TOKEN)
->withOAuth2Credential($auth)
->withClientCustomerId($client->getCustomerId())
->build();

$reportDownloader = new ReportDownloader($clientSession);
$reportSettingsOverride = (new ReportSettingsBuilder())->includeZeroImpressions(false)->build();
$reportDownloadResult = $reportDownloader->downloadReport(
$reportDefinition,
$reportSettingsOverride
);

//dd(explode(',',$reportDownloadResult->getAsString()));
$array = explode(PHP_EOL,$reportDownloadResult->getAsString());
foreach($array as $n => $row)
{
if($n == (count($array) - 1))
unset($array[$n]);
}
foreach($array as $n => $row)
{
if($n == (count($array) - 1)){
$account = explode(',',$row);
$accounts[] = [
'account' => $client->getName(),
'Clicks' => $account[1],
'Impressions' => $account[2],
'Ctr' => $account[3],
'Conversions' => $account[4],
'ConversionRate' => $account[5],
'Cost' => $account[6],
'AveragePosition' => $account[7],
'AverageCpc' => $account[8]
];
}
}

//dd($accounts);
}

$accounts = collect($accounts);

Bharani Cherukuri (AdWords API Team)

unread,
Sep 20, 2018, 2:12:53 PM9/20/18
to AdWords API and Google Ads API Forum
Hello Albert, 

I was able to generate the Account Performance Report with the same report query without any latency. Can you try generating the report with a shorter date range or use predicates to break up the report request into multiple, smaller requests to avoid the delay? If you continue to have an issue with this, could you share the CID specified in the request header so I can take a look? You can reply back via Reply privately to author option.

Thanks,
Bharani, AdWords API Team

Reply all
Reply to author
Forward
0 new messages