I developed a python script to extract search volumes against keywords.
I use a developer token with basic access, but in my output I only ever
receive dummy values like "search volume: 0/10" etc.. Why?
from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException
# Carica le credenziali dal file YAML
client = GoogleAdsClient.load_from_storage("google-ads.yaml")
def get_keyword_ideas(client, customer_id, keywords, geo_target_id,
language_id):
# Ottieni il servizio
keyword_plan_idea_service = client.get_service("KeywordPlanIdeaService")
# Configura la richiesta
request = client.get_type("GenerateKeywordIdeasRequest")
request.customer_id = customer_id
request.language = f"languageConstants/{language_id}" # Es. "1000" per
Inglese
request.geo_target_constants.append(f"geoTargetConstants/{geo_target_id}
") # Es. ID per l'Italia
request.keyword_seed.keywords.extend(keywords)
request.page_size = 5
# request.url_seed.url = url # URL da cui generare idee
# Imposta la rete di ricerca come Google Search and Partners
request.keyword_plan_network = client.enums.KeywordPlanNetworkEnum.
GOOGLE_SEARCH_AND_PARTNERS
try:
response = keyword_plan_idea_service.generate_keyword_ideas(request)
for result in response:
# Estrazione del CPC medio
cpc_micros = result.keyword_idea_metrics.average_cpc_micros
cpc = cpc_micros / 1_000_000 if cpc_micros else "N/A" #
Converte i micros in valuta normale
print(
f"Keyword: {result.text}, "
f"Vol. ricerche mese: {
result.keyword_idea_metrics.avg_monthly_searches}, "
f"Competition: {result.keyword_idea_metrics.competition}, "
f"CPC: {cpc} "
)
except GoogleAdsException as ex:
print(f"Request ID: {ex.request_id}")
for error in ex.failure.errors:
print(f"Error Code: {error.error_code}")
print(f"Message: {error.message}")
# Esegui la funzione
customer_id = "311XXXXXXX" # Sostituisci con il tuo Customer ID
keywords = ["infissi legno", "porta finestra", "infissi alluminio", "finestre
fermo", "finiture"] # Parole chiave da analizzare
geo_target_id = "21167" # ID geografico per l'Italia
language_id = "1001" # ID lingua (1000 = Inglese, 1001 = Italiano)
# url = "http://www.faipgruppo.it/"
get_keyword_ideas(client, customer_id, keywords, geo_target_id, language_id)
OUTPUT:
Keyword: infissi legno, Vol. ricerche mese: 10, Competition: 0, CPC: N/A
Keyword: porta finestra, Vol. ricerche mese: 10, Competition: 2, CPC: N/A
Keyword: infissi alluminio, Vol. ricerche mese: 10, Competition: 0, CPC:
N/A
Keyword: finiture, Vol. ricerche mese: 10, Competition: 4, CPC: N/A
Keyword: finestre e serramenti in pvc, Vol. ricerche mese: 0, Competition:
0, CPC: N/A
Keyword: finitura, Vol. ricerche mese: 10, Competition: 2, CPC: N/A
Keyword: finiture case prefabbricate, Vol. ricerche mese: 0, Competition:
0, CPC: N/A
Keyword: infissi in alluminio vendita on line, Vol. ricerche mese: 0,
Competition: 0, CPC: N/A
Keyword: infissi legno e alluminio taglio termico, Vol. ricerche mese: 0,
Competition: 0, CPC: N/A
Keyword: inox scotch brite, Vol. ricerche mese: 10, Competition: 0, CPC:
N/A
Keyword: oikos travertino romano finitura, Vol. ricerche mese: 0,
Competition: 0, CPC: N/A
Keyword: porte e finestre blindate prezzi, Vol. ricerche mese: 0,
Competition: 0, CPC: N/A
Keyword: porte finestre in pvc costi, Vol. ricerche mese: 10, Competition:
0, CPC: N/A
Keyword: travertino romano finitura, Vol. ricerche mese: 0, Competition: 0,
CPC: N/A
Keyword: vendita finestre alluminio, Vol. ricerche mese: 0, Competition: 0,
CPC: N/A
Keyword: finestre fermo, Vol. ricerche mese: 0, Competition: 0, CPC: N/A
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/372592c8-78d5-4aee-b266-9a6b9485650bn%40googlegroups.com.