Dear, I'm trying to build a small tool to do keyword research via my tool and automatically add it to google sheets, to make it easier to get keyword ideas.
The problem i am facing is that for the same word 'Bedrijfsfilm', with same
parameters like network ( google ), language constant Netherlands (1017)
and geo target constants ( 2528 ).
I am getting only 2 results via my tool, but with the ads keywordplanner i
get 39 results, a lot more concepts. What can i do to retrieve the same
ideas via the API?
[response:Google\ApiCore\Page:private] =>
Google\Ads\GoogleAds\V16\Services\GenerateKeywordIdeaResponse Object
(
[results] => Array
(
[0] => Array
(
[text] => bedrijfsfilm
[keywordIdeaMetrics] => Array
(
[avgMonthlySearches] => 320
[monthlySearchVolumes] => Array
(
[0] => Array
(
[year] => 2024
[month] =>
JANUARY
[monthlySearches] => 390
)
[1] => Array
(
[year] => 2024
[month] =>
FEBRUARY
[monthlySearches] => 390
)
[2] => Array
(
[year] => 2024
[month] => MARCH
[monthlySearches] => 390
)
[3] => Array
(
[year] => 2024
[month] => APRIL
[monthlySearches] => 390
)
[4] => Array
(
[year] => 2024
[month] => MAY
[monthlySearches] => 390
)
[5] => Array
(
[year] => 2024
[month] => JUNE
[monthlySearches] => 320
)
[6] => Array
(
[year] => 2024
[month] => JULY
[monthlySearches] => 260
)
[7] => Array
(
[year] => 2024
[month] =>
AUGUST
[monthlySearches] => 170
)
[8] => Array
(
[year] => 2024
[month] =>
SEPTEMBER
[monthlySearches] => 210
)
[9] => Array
(
[year] => 2024
[month] =>
OCTOBER
[monthlySearches] => 260
)
[10] => Array
(
[year] => 2024
[month] =>
NOVEMBER
[monthlySearches] => 260
)
[11] => Array
(
[year] => 2024
[month] =>
DECEMBER
[monthlySearches] => 170
)
)
[competition] => MEDIUM
[competitionIndex] => 51
[lowTopOfPageBidMicros] =>
3292875
[highTopOfPageBidMicros] =>
7336318
)
[keywordAnnotations] => Array
(
)
)
[1] => Array
(
[text] => promotiefilm maken kosten
[keywordIdeaMetrics] => Array
(
[avgMonthlySearches] => 10
[monthlySearchVolumes] => Array
(
[0] => Array
(
[year] => 2024
[month] =>
JANUARY
[monthlySearches] => 10
)
[1] => Array
(
[year] => 2024
[month] =>
FEBRUARY
[monthlySearches] => 10
)
[2] => Array
(
[year] => 2024
[month] => MARCH
[monthlySearches] => 10
)
[3] => Array
(
[year] => 2024
[month] => APRIL
[monthlySearches] => 10
)
[4] => Array
(
[year] => 2024
[month] => MAY
[monthlySearches] => 10
)
[5] => Array
(
[year] => 2024
[month] => JUNE
[monthlySearches] => 10
)
[6] => Array
(
[year] => 2024
[month] => JULY
[monthlySearches] => 10
)
[7] => Array
(
[year] => 2024
[month] =>
AUGUST
[monthlySearches] => 10
)
[8] => Array
(
[year] => 2024
[month] =>
SEPTEMBER
[monthlySearches] => 10
)
[9] => Array
(
[year] => 2024
[month] =>
OCTOBER
[monthlySearches] => 10
)
[10] => Array
(
[year] => 2024
[month] =>
NOVEMBER
[monthlySearches] => 10
)
[11] => Array
(
[year] => 2024
[month] =>
DECEMBER
[monthlySearches] => 10
)
)
[competition] => MEDIUM
[competitionIndex] => 57
[lowTopOfPageBidMicros] =>
5082079
[highTopOfPageBidMicros] =>
8450479
)
[keywordAnnotations] => Array
(
[concepts] => Array
(
[0] => Array
(
[name] =>
Non-Brands
[conceptGroup]
=> Array
(
[name]
=> 非品牌
[type]
=> NON_BRAND
)
)
)
)
)
)
[totalSize] => 2
)
public function getKeywordIdeasByUrlOrWord($clientCustomerId, $input,
$languageId, $locationIds = [], $pageUrl = null) {
$keywordPlanIdeaServiceClient = $this->client->
getKeywordPlanIdeaServiceClient();
// Create an empty HistoricalMetricsOptions instance
$historicalMetricsOptions = new HistoricalMetricsOptions();
$requestParams = [
'customer_id' => $clientCustomerId,
'language' => $languageId,
'keyword_plan_network' => KeywordPlanNetwork::GOOGLE_SEARCH,
'geo_target_constants' => $locationIds,
'historical_metrics_options' => $historicalMetricsOptions,
'include_adult_keywords' => true,
'keyword_annotation' => [
KeywordPlanKeywordAnnotation::KEYWORD_CONCEPT,
],
'page_size' => 10000
];
if ($pageUrl && $input) {
$requestParams['keyword_and_url_seed'] = new KeywordAndUrlSeed([
'keywords' => [$input],
'url' => $pageUrl
]);
} elseif ($pageUrl) {
$requestParams['url_seed'] = new UrlSeed(['url' => $pageUrl]);
} elseif ($input) {
$keywords = explode(',', $input);
if( count($keywords) > 1 ) {
$requestParams['keyword_seed'] = new KeywordSeed(['keywords'
=> $keywords]);
} else {
$requestParams['keyword_seed'] = new KeywordSeed(['keywords'
=> [$input]]);
}
}
$request = new GenerateKeywordIdeasRequest($requestParams);
try {
$response = $keywordPlanIdeaServiceClient->generateKeywordIdeas
($request);
} catch (\Exception $e) {
error_log('Error generating keyword ideas: ' . $e->getMessage
());
throw $e;
}
$keywordIdeas = [];
error_log( print_r( $response, true ) );
foreach ($response->iterateAllElements() as $result) {
$metrics = $result->getKeywordIdeaMetrics();
error_log( print_r( $result->getKeywordAnnotations(), true ) );
$monthlySearchVolumes = [];
if ($metrics && $metrics->getMonthlySearchVolumes()->count() > 0)
{
foreach ($metrics->getMonthlySearchVolumes() as
$monthlyVolume) {
$year = $monthlyVolume->getYear();
$monthNumber = $monthlyVolume->getMonth();
$searches = $monthlyVolume->getMonthlySearches();
$monthName = DateTime::createFromFormat('!m',
$monthNumber)->format('M');
$monthlySearchVolumes[] = [
'year' => $year,
'month' => $monthName,
'searches' => $searches,
];
}
}
$keywordIdeas[] = [
'keyword' => $result->getText(),
'avg_monthly_searches' => $metrics ? $metrics->
getAvgMonthlySearches() : 'N/A',
'competition' => $metrics ? KeywordPlanCompetitionLevel::
name($metrics->getCompetition()) : 'N/A',
'competition_index' => $metrics ? $metrics->
getCompetitionIndex() : 'N/A',
'low_top_of_page_bid' => $metrics && $metrics->
hasLowTopOfPageBidMicros() ? $metrics->getLowTopOfPageBidMicros() /
1_000_000 : 'none',
'high_top_of_page_bid' => $metrics && $metrics->
hasHighTopOfPageBidMicros() ? $metrics->getHighTopOfPageBidMicros() /
1_000_000 : 'none',
'monthly_search_volumes' => $monthlySearchVolumes,
];
}
return $keywordIdeas;
}
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 visit
https://groups.google.com/d/msgid/adwords-api/0eeabadb-ebcd-4eb8-aced-3041a7770170n%40googlegroups.com.
