How to get the FinalUrls related to the Keywords

71 views
Skip to first unread message

Karim Benna

unread,
Feb 17, 2016, 4:59:11 AM2/17/16
to AdWords API Forum
Hi everyone,

I have a small issue, i'm trying to call the final Urls  related to the keywords in Java and i don't find the way. I could make it for the ads this is the code :

I need to do the same thing but for keywords! PLEASE HELP




AdGroupAdServiceInterface adService =
       adWordsServices.get(session, AdGroupAdServiceInterface.class);

SelectorBuilder builder = new SelectorBuilder();
   Selector selector = builder
       .fields(AdGroupAdField.CreativeFinalUrls, AdGroupAdField.AdGroupId)
       .orderAscBy(AdGroupAdField.AdGroupId)
       .offset(offset)
       .limit(PAGE_SIZE)
       .build();


AdGroupAdPage page = null;
   do {
     page = adService.get(selector);

      if (page.getEntries() != null) {
       for (AdGroupAd ad: page.getEntries()) {
       try{
         System.out.println("Ad with url \"" + ad.getAd().getFinalUrls()[0] + "\" and id \""
             + ad.getAd().getId() + "\" was found. And Status: " + ad.getStatus());
         
       }
       catch(NullPointerException e){
            System.out.println("A campaign of this GroupAd: " + campaign.getAdGroupId() + " is :" + campaign.getStatus());
       }
         
       }
     } else {
       System.out.println("No ads were found.");
     }
     offset += PAGE_SIZE;
     selector = builder.increaseOffsetBy(PAGE_SIZE).build();
   } while (offset < page.getTotalNumEntries());
 }

Anthony Madrigal

unread,
Feb 17, 2016, 11:28:52 AM2/17/16
to AdWords API Forum
Hello Karim,

The final Url of a keyword can be set by using the AdGroupCriterionService. The BiddableAdGroupCriterion has the field finalUrls which you can use. 

While the GetKeywords example does not show how to get the final Url, it does show how to use the service.

Cheers,
Anthony
AdWords API Team

Karim Benna

unread,
Mar 1, 2016, 8:46:13 AM3/1/16
to AdWords API Forum
Thank you Anthony but i'm trying to GET the finalUrls related to the keywords ( so on Keyword level) but i don't find a way.

Kind regards.

Anthony Madrigal

unread,
Mar 1, 2016, 2:36:10 PM3/1/16
to AdWords API Forum
Hi Karim,

I had sent you an email previously. I guess it must not have sent properly.

You can modify the GetKeywords example I provided you as the following in order to get the final Url.
 Keyword keyword = (Keyword) adGroupCriterionResult.getCriterion();
 
BiddableAdGroupCriterion biddableAdGroupCriterion= (BiddableAdGroupCriterion) adGroupCriterionResult;
 
biddableAdGroupCriterion.getFinalUrls();

giorgio...@gmail.com

unread,
Mar 2, 2016, 5:20:32 AM3/2/16
to AdWords API Forum
I didnt understand the BiddableAdGroupCriterion to get the finalUrls from the keywords on PHP.
Im running the GetKeywords script in this way:

$adGroupCriterionService = $user->GetService('AdGroupCriterionService', ADWORDS_VERSION);
$adGroupCriterion = new BiddableAdGroupCriterion();

Then I get the fields: text, matchtype, id, type, criteriontype but if I try to add the field

$adGroupCriterion->criterion->finalUrls;

I dont get anything.

giorgio...@gmail.com

unread,
Mar 2, 2016, 9:08:40 AM3/2/16
to AdWords API Forum
Solved using $adGroupCriterion->finalUrls->urls[0]
Reply all
Reply to author
Forward
0 new messages