CampaignService class not support to get impression details

13 views
Skip to first unread message

Soniya kaliappan

unread,
Jul 26, 2018, 3:21:05 AM7/26/18
to AdWords API and Google Ads API Forum
I need get all campaign details order by impression .

My Sample code :- 

$oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();
$session = (new AdWordsSessionBuilder())->fromFile()->withOAuth2Credential($oAuth2Credential)->build();
$adWordsServices =  new AdWordsServices();
$campaignService = $adWordsServices->get($session, CampaignService::class);
$selector = new Selector();
$selector->setFields(['CampaignName','CampaignStatus','Amount','Impressions']);
$selector->setOrdering([new OrderBy('Impressions','ASCENDING')]);
$selector->setPaging(new Paging(0,2));
$page = $campaignService->get($selector);

I got Below Error :- 

Google\AdsApi\AdWords\v201802\cm\SelectorError Object
(
    [reason:protected] => INVALID_FIELD_NAME
    [fieldPath:protected] => serviceSelector
    [fieldPathElements:protected] => Array
        (
            [0] => Google\AdsApi\AdWords\v201802\cm\FieldPathElement Object
                (
                    [field:protected] => serviceSelector
                    [index:protected] => 
                )

        )

    [trigger:protected] => Amount
    [errorString:protected] => SelectorError.INVALID_FIELD_NAME
    [ApiErrorType:protected] => SelectorError
    [parameterMap:Google\AdsApi\AdWords\v201802\cm\ApiError:private] => Array
        (
            [ApiError.Type] => ApiErrorType
        )

)

So , I think CampaignService class does not support to get campaign impression,clicks details . May I know , which class I have to use to get campaign impression,click and other details . Please  help me . 

Peter Oliquino (AdWords API Team)

unread,
Jul 26, 2018, 4:36:37 AM7/26/18
to AdWords API and Google Ads API Forum
Hi Soniya,

Metrics such as Impressions are only available through the reports and not through the AdWords API services. In your scenario, you can use the Campaign Performance Report to get your campaign-level Impressions. However, you may take note that ordering is not supported in the AdWords API's reports, for more information, you may refer here.

You may need to implement such a feature on your end after you have downloaded the report.

Thanks and regards,
Peter
AdWords API Team
Reply all
Reply to author
Forward
0 new messages