Hello, AdGroupAdService.get only returns ads (or, in your case TextAds). If you look at the TextAd API <https://developers.google.com/adwords/api/docs/reference/v201409/AdGroupAdService.TextAd> you will notice that CPC, cost, CTR, impressions, etc. are not available. To get these performance values I recommend downloading an ad performance report <https://developers.google.com/adwords/api/docs/appendix/reports#ad>.
Stacie On Thursday, January 8, 2015 at 5:44:32 AM UTC-8, Kiran Kumar wrote: > > > > Hi , > > I am trying to get the CPC,cost,CTR ,impressions using GetTextAds ,but > it's only giving like adtext ,headline and urls but not the others > > How do I retrieve this values using API ? > > Thank you ? > > > Code: > > > function GetTextAdsExample(AdWordsUser $user, $adGroupId) { > // Get the service, which loads the required classes. > $adGroupAdService = $user->GetService('AdGroupAdService', ADWORDS_VERSION); > > // Create selector. > $selector = new Selector(); > $selector->fields = array('Headline', 'Id'); > $selector->ordering[] = new OrderBy('Headline', 'ASCENDING'); > > // Create predicates. > $selector->predicates[] = new Predicate('AdGroupId', 'IN', > array($adGroupId)); > $selector->predicates[] = new Predicate('AdType', 'IN', > array('TEXT_AD')); > // By default disabled ads aren't returned by the selector. To return > them > // include the DISABLED status in a predicate. > $selector->predicates[] = > new Predicate('Status', 'IN', array('ENABLED', 'PAUSED', 'DISABLED')); > > // Create paging controls. > $selector->paging = new Paging(0, > AdWordsConstants::RECOMMENDED_PAGE_SIZE); > > do { > // Make the get request. > $page = $adGroupAdService->get($selector); > > // Display results. > if (isset($page->entries)) { > foreach ($page->entries as $adGroupAd) { > global $retval; > $head=$adGroupAd->ad->headline; > $adid=$adGroupAd->ad->id; > $des1=$adGroupAd->ad->description1; > $des2=$adGroupAd->ad->description2; > $url=$adGroupAd->ad->displayUrl; > $clicks=$adGroupAd->stats->clicks; > $cpc=$adGroupAd->stats->averageCpc->microAmount / 1000000; > $conversions=$adGroupAd->stats->conversions; > $cost=$adGroupAd->stats->cost->microAmount / 1000000; > $ctr=$adGroupAd->stats->ctr; > $imp=$adGroupAd->stats->impressions; > $ap=$adGroupAd->stats->averagePosition; > //printf("Text ad with headline '%s' and ID '%s' was found.\n", > //$adGroupAd->ad->headline, $adGroupAd->ad->id); > array_push($retval,array("hea"=>$head,"id"=>$adid ,"desc"=>$des1 > ,"desc2"=>$des2,"url"=>$url, > > "cli"=>$clicks,"cpc"=>$cpc,"con"=>$conversions,"cost"=>$cost,"ctr"=>$ctr,"imp"=>$imp,"ap"=>$ap > )); > } > echo json_encode($retval); > } else { > //print "No text ads were found.\n"; > } > > // Advance the paging index. > $selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE; > } while ($page->totalNumEntries > $selector->paging->startIndex); > } > > > try { > // Get AdWordsUser from credentials in "../auth.ini" > // relative to the AdWordsUser.php file's directory. > $user = new AdWordsUser(); > > // Log every SOAP XML request and response. > $user->LogAll(); > > // Run the example. > GetTextAdsExample($user, $adGroupId); > } catch (Exception $e) { > printf("An error has occurred: %s\n", $e->getMessage()); > } > -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog and Google+: https://googleadsdeveloper.blogspot.com/ https://plus.google.com/+GoogleAdsDevelopers/posts =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API Forum" group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en --- You received this message because you are subscribed to the Google Groups "AdWords API Forum" group. To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/adwords-api. To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/63cd610f-c130-4627-a375-b89460085bd0%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.