radius referenced targeting criteria

23 views
Skip to first unread message

Dominik Raffetseder

unread,
Jan 10, 2018, 3:32:47 AM1/10/18
to AdWords API Forum
Hello,

i tried to get the location where an specified campaign is shown. With the following code this works perfect. My campaign is active in Mannheim and in Mannheim with radius 50 kilometer. 
The Problem is the API does shown only the real mannheim, and doesn't response the Mannheim with radius, so i dont' get data for this?
How can i solve this problem?


First Picture: Selected in Adwords
Second Picture: Result from API


class GetCampaignTargetingCriteria {


  public static function runExample(AdWordsServices $adWordsServices,
      AdWordsSession $session, $campaignId,$CustomerId,$kuerzel) {
    global $DBH;
    $campaignCriterionService =
        $adWordsServices->get($session, CampaignCriterionService::class);

    $sql="SELECT ac.campaign_id, ac.kuerzel_land,ac.status from adwords_campaign ac where  ac.customer_id=".$CustomerId;
    echo $sql."<br>";
  
    try { 
      $STH_out= $DBH->query($sql);
    } catch(PDOException $e) { 
       echo "Es ist ein Fehler aufgetreten getCampaigns-1: {$e->getMessage()} "; 
      file_put_contents('PDOErrors.txt', $e->getMessage()." getCampaigns-111111", FILE_APPEND); 
    }
    $STH_out->setFetchMode(PDO::FETCH_ASSOC); 
       
    while($row = $STH_out->fetch()) { 
    $campaignarray[$row['campaign_id']][0]= $row['kuerzel_land']; 
    $campaignarray[$row['campaign_id']][1]= $row['status']; 
    }


    // Create a selector to select all campaign criteria for the specified
    // campaign.
    $locale = 'DE';
    $selector = new Selector();
    $selector->setFields(['Id', 'CriteriaType','CampaignId','LocationName','ParentLocations','TargetingStatus']);
    $selector->setPredicates([
       // new Predicate('CampaignId', PredicateOperator::IN, [$campaignId])/*,
        new Predicate('CriteriaType', PredicateOperator::IN,
            ['LOCATION']),
        //new Predicate('LanguageCode', PredicateOperator::EQUALS, [$locale])
    ]);
    $selector->setPaging(new Paging(0, self::PAGE_LIMIT));

   
    $c=0;
    do {
      // Retrieve campaign criteria one page at a time, continuing to request
      // pages until all campaign criteria have been retrieved.
      $page = $campaignCriterionService->get($selector);

      // Print out some information for each campaign criterion.
      if ($page->getEntries() !== null) {
        $totalNumEntries = $page->getTotalNumEntries();
        foreach ($page->getEntries() as $campaignCriterion) {
          $CampaignId = $campaignCriterion->getCampaignId();
          $CriterionId = $campaignCriterion->getCriterion()->getId();
          $LocationName = $campaignCriterion->getCriterion()->getLocationName();
          $TargetingStatus = $campaignCriterion->getCriterion()->getTargetingStatus();
          $TargetType = $campaignCriterion->getCriterion()->getDisplayType();


Bildschirmfoto 2018-01-10 um 09.31.03.png
Result.png

Vincent Racaza (AdWords API Team)

unread,
Jan 10, 2018, 5:33:00 AM1/10/18
to AdWords API Forum
Hi Dominik,

You can get the radius of your location using radiusInUnits of the Proximity object. You can use the CampaignCriterionService.get() on which you are currently using, or the CampaignCriterionService.query() to get this information.

Let me know if you have further clarifications.

Thanks,
Vincent
AdWords API Team
Reply all
Reply to author
Forward
0 new messages