AdGroupAd status incorrect?

169 views
Skip to first unread message

James

unread,
Feb 18, 2016, 11:16:45 AM2/18/16
to AdWords API Forum
Hello,

Sorry if this has been covered, or if I have made a silly error... 

I am trying to use the AdGroupAdService to find the Final / Destination URLs for the ads we manage (there are about 6000 or so). 
This part seems okay. But I want to only deal with our ads that are active, so i have been looking at the status field to see which are set to "ENABLED". 
But often ads that are paused, or are within a campaign that is paused, or even in an account that is deactivated return with a status of ENABLED. 

Is that expected behaviour, or have I made an error? 

Thanks!
James


<?php

require_once '/apimaster/examples/AdWords/v201506/init.php';

$user = new AdWordsUser();
$account = '{account number removed}';

$user->SetClientCustomerId($account);

$adGroupAdService = $user->GetService('AdGroupAdService', ADWORDS_VERSION);

$selector = new Selector();
$selector->fields = array('CreativeFinalUrls', 'Status');

// Create paging controls.
$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);

$page = $adGroupAdService->get($selector);

if(!empty($page->entries)) {
foreach ($page->entries as $adgroup) {

$adgroupid = $adgroup->adGroupId;
$status = $adgroup->status;
$headline = $adgroup->ad->headline;
$description1 = $adgroup->ad->description1;
$description2 = $adgroup->ad->description2;
$normalurl = $adgroup->ad->url;
$finalurl = $adgroup->ad->finalUrls;
$displayurl = $adgroup->ad->displayUrl;
$id = $adgroup->ad->id;

if ($status === "ENABLED") {
        [...]

Yin Niu

unread,
Feb 18, 2016, 11:54:09 AM2/18/16
to AdWords API Forum
Hi James, 

You are checking on AdGroup status instead of AdGroupAd status in your code. In your selector, you can add a predicate where AdGroupAd.status == "ENABLED" so that you don't have to loop through all results. 

Thanks,
Yin, AdWords API Team.  

James

unread,
Feb 19, 2016, 5:52:01 AM2/19/16
to AdWords API Forum
Hi Yin,

Thanks for your super fast response.

I know that i have called the variable $adgroup, but I think this is actually the AdGroupAd object. (each of the page -> entries) 

I'm currently selecting the entry's status: 

AdGroupAdPage Object
(
    [entries] => Array
        (
            [0] => AdGroupAd Object
                (
                    [adGroupId] => 25347XXXXX
                    [ad] => ProductAd Object
                        (
                            [promotionLine] => 
                            [id] => 81178XXXXXX
                            [url] => 
                            [displayUrl] => 
                            [finalUrls] => www.google.com
                            [finalMobileUrls] => 
                            [finalAppUrls] => 
                            [trackingUrlTemplate] => 
                            [urlCustomParameters] => 
                            [devicePreference] => 
                            [AdType] => ProductAd
                            [_parameterMap:Ad:private] => Array
                                (
                                    [Ad.Type] => AdType
                                )

                        )

                    [experimentData] => 
                    [status] => ENABLED
                    [approvalStatus] => UNCHECKED
                    [trademarks] => 
                    [disapprovalReasons] => 
                    [trademarkDisapproved] => 
                    [labels] => 
                    [forwardCompatibilityMap] => 
                )

        )

    [totalNumEntries] => 1
    [PageType] => AdGroupAdPage
    [_parameterMap:Page:private] => Array
        (
            [Page.Type] => PageType
        )

)


From the AdGroupAd selector guide it looks like adGroupAd.status is accessed at entries->status



I've added a new predicate (
$selector->predicates[] = new Predicate('Status', 'EQUALS', 'ENABLED');

but I still get a lot of results where the status is enabled even though the ad, or adgroup or campaign or account are paused / disabled.

Thanks again for your help!
James

Yin Niu

unread,
Feb 19, 2016, 9:44:00 AM2/19/16
to AdWords API Forum
Hi James, 

I can not reproduce your problem. Please send the SOAP request and response so that I can investigate further. 

James

unread,
Feb 19, 2016, 10:45:27 AM2/19/16
to AdWords API Forum

Okay, I've attached (hopefully the correct) log and removed my developer token.

Some of the ads here (with id 8840406794 for example) are not active, despite having an ENABLED status.

Thanks once again!
James
request-log.rtf

Yin Niu

unread,
Feb 19, 2016, 10:58:16 AM2/19/16
to AdWords API Forum
Hi James, 

I see that in the response, all returned ads have "ENABLED" status. Could you point out to me which ad that was return as "ENABLED" but has actual status not set to "ENABLED"? 

James

unread,
Feb 19, 2016, 11:01:59 AM2/19/16
to AdWords API Forum
I haven't been able to check them all, but one example is the ad with ID 8840406794 (adgroup ID 2336016314).

Thanks again,
J

Yin Niu

unread,
Feb 19, 2016, 11:35:42 AM2/19/16
to AdWords API Forum
Hi James, 

That is expected behavior. API only returns the requested object's status, not it's serving status (which is "not serving, because campaign is paused") If they retrieve the campaign's status, they will get it back as PAUSED.

Say if you want to filter out these ads in a report, then you could write an AWQL like "Select CampaignId, AdGroupId, AdId from AD_PERFORMANCE_REPORT where CampaignStatus = ENABLED and AdGroupStatus=ENABLED and AdStatus=ENABLED".

James

unread,
Feb 19, 2016, 12:08:17 PM2/19/16
to AdWords API Forum

Great,

Thank you very much for your help!

James
Reply all
Reply to author
Forward
0 new messages