Same keywords are coming in different adgroup

18 views
Skip to first unread message

hemant dhote

unread,
Apr 10, 2023, 8:25:35 AM4/10/23
to Google Ads API Forum Advisor, adwor...@googlegroups.com
Hi I need some help 

when we fetch keywords from adgroup api.so we get the same keywords in different ad groups.
We want to know if a keyword can be in a different argroup or is the api a mistake ? used this below api.

public static function runGetKeyword(
        GoogleAdsClient $googleAdsClient,
        int $customerId,
        ?int $adGroupId,
    ) {
        $googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();
        // Creates a query that retrieves keywords.
        $query =
          'SELECT ad_group.id, '
              . 'ad_group.name, '
              . 'campaign.id, '
              . 'campaign.name, '
              . 'ad_group_criterion.type, '              
              . 'ad_group_criterion.criterion_id, '
              . 'ad_group_criterion.keyword.text, '
              . 'ad_group_criterion.keyword.match_type, '
              . 'ad_group_criterion.status, '
              . 'ad_group_criterion.labels '
          . 'FROM ad_group_criterion '
          . 'WHERE ad_group_criterion.type = KEYWORD';
        if ($adGroupId !== null) {
            $query .= " AND ad_group.id = $adGroupId";
            $query .= " AND ad_group_criterion.status = 'ENABLED' ";
        }

        // Issues a search request by specifying page size.
        $response =
            $googleAdsServiceClient->search($customerId, $query, []);

        $keywords = [];
        foreach ($response->iterateAllElements() as $googleAdsRow) {
            /* @var GoogleAdsRow $googleAdsRow /
            $adgroupcreation_status = new AdGroupCriterionStatus();
            $status = $adgroupcreation_status->name($googleAdsRow->getAdGroupCriterion()->getStatus());
            $keywords[] = ['keyword_id'=>$googleAdsRow->getAdGroupCriterion()->getCriterionId(), 'labels' =>$googleAdsRow->getAdGroupCriterion()->getLabels(), 'keyword_text'=>$googleAdsRow->getAdGroupCriterion()->getKeyword()->getText(),
                'keyword_match_type'=> KeywordMatchType::name(
                    $googleAdsRow->getAdGroupCriterion()->getKeyword()->getMatchType()
                ),
                'keyword_criteria_type' =>  CriterionType::name($googleAdsRow->getAdGroupCriterion()->getType()), 'status' => $status, 'campaign_name' => $googleAdsRow->getCampaign()->getName(), 'campaign_id' => $googleAdsRow->getCampaign()->getId(), 'adgroup_id' => $googleAdsRow->getAdGroup()->getId() , 'adgroup_name' => $googleAdsRow->getAdGroup()->getName() ];
        }
     
        return $keywords;
    }

Google Ads API Forum Advisor

unread,
Apr 11, 2023, 4:33:23 AM4/11/23
to hdh...@gmail.com, adwor...@googlegroups.com

Hi,

You have now reached the Google Ads API support team. We hope that today is going well for you!

In order to check this on our end, can you please provide the complete logs within the format provided below that were generated on your end?

request - https://developers.google.com/google-ads/api/docs/concepts/field-service#request
response https://developers.google.com/google-ads/api/docs/concepts/field-service#response
request ID -  https://developers.google.com/google-ads/api/docs/concepts/call-structure#request-id
request header - https://developers.google.com/google-ads/api/docs/concepts/call-structure#request_headers

Also, the whole screenshot of the Google Ads UI that you want to get via API is helpful on our investigations. If you haven't yet, logging can be enabled by referring to this guide (https://developers.google.com/google-ads/api/docs/best-practices/logging?hl=en) and using the DEBUG log setting. This information will help our team better check this and provide guidance accordingly.

You may then send the requested logs via the Reply privately to the author option. If this option is not available, you may send the details directly to our googleadsa...@google.com alias instead.

Best regards,

Google Logo Google Ads API Team


ref:_00D1U1174p._5004Q2kTfIf:ref
Reply all
Reply to author
Forward
0 new messages