keyword_idea_metrics.avg_monthly_searches

48 views
Skip to first unread message

Webdev

unread,
Jan 22, 2025, 4:19:46 AM1/22/25
to Google Ads API and AdWords API Forum
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)

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

Google Ads API Forum Advisor

unread,
Jan 22, 2025, 6:47:59 AM1/22/25
to web...@webicom.it, adwor...@googlegroups.com

Hi,

Thank you for contacting the Google Ads API support team.

I understand that you're receiving dummy values like "search volume: 0/10" when fetching search volumes for keywords using the API. To investigate the issue further and replicate the issue from our end, could you please provide the following:

  • The Customer ID (CID) of your Google Ads account.

  • An uncropped screenshot from the Google Ads UI showing the average search volume for the same keywords you're querying via the API.

You can send the details via the Reply privately to the author option or a direct private reply to this email. 

This message is in relation to case "ref:!00D1U01174p.!5004Q02vGxsd:ref" (ADR-00285446)

Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5


 


Reply all
Reply to author
Forward
0 new messages