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;
}
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
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
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/CAMd9mKsyd%2BNvWr8jF4MLFBLi4KDcgRKQnEr0dpc0br8T4Gn4HQ%40mail.gmail.com.