Keyword Planner API - getting just U.S historical stats

53 views
Skip to first unread message

Maciek eF

unread,
Feb 22, 2023, 9:20:05 AM2/22/23
to Google Ads API and AdWords API Forum
Hi dear members,
I have problem with keyword planner API.
I set polish language and Poland as geo target in create_keyword_plan_campaign, but I get just stats from USA (for example program do faktur shows in API just 10 approximate monthly searches, but in UI keywordplanner I can see around 6,600 monthly searches. What have I done wrongly?

Thanks for your help in advance.

def create_keyword_plan_campaign(client, customer_id, keyword_plan):
    """Adds a keyword plan campaign to the given keyword plan.
    Args:
        client: An initialized instance of GoogleAdsClient
        customer_id: A str of the customer_id to use in requests.
        keyword_plan: A str of the keyword plan resource_name this keyword plan
            campaign should be attributed to.create_keyword_plan.
    Returns:
        A str of the resource_name for the newly created keyword plan campaign.
    Raises:
        GoogleAdsException: If an error is returned from the API.
    """
    keyword_plan_campaign_service = client.get_service(
        "KeywordPlanCampaignService"
    )
    operation = client.get_type("KeywordPlanCampaignOperation")
    keyword_plan_campaign = operation.create

    keyword_plan_campaign.name = f"Keyword plan campaign {uuid.uuid4()}"
    keyword_plan_campaign.cpc_bid_micros = 100000000
    keyword_plan_campaign.keyword_plan = keyword_plan

    network = client.enums.KeywordPlanNetworkEnum.GOOGLE_SEARCH
    keyword_plan_campaign.keyword_plan_network = network

    geo_target = client.get_type("KeywordPlanGeoTarget")
    # Constant for U.S. Other geo target constants can be referenced here:
    # https://developers.google.com/google-ads/api/reference/data/geotargets
    geo_target.geo_target_constant = "geoTargetConstants/2840"
    keyword_plan_campaign.geo_targets.append(geo_target)

    # Constant for English
    language = "languageConstants/1030"
    keyword_plan_campaign.language_constants.append(language)

    response = keyword_plan_campaign_service.mutate_keyword_plan_campaigns(
        customer_id=customer_id, operations=[operation]
    )

    resource_name = response.results[0].resource_name

    print(f"Created keyword plan campaign with resource name: {resource_name}")

    return resource_name

Google Ads API Forum Advisor

unread,
Feb 22, 2023, 3:36:20 PM2/22/23
to maciek.f...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for posting your concern to the Google Ads API.

Regarding your concern, kindly note that the Google Ads API and Google Ads UI mirrors each other. Meaning by using the Google Ads API, you can retrieve and manage the data that you are seeing in the Google Ads UI programmatically. Having said that, so our team can fully check and investigate this issue, can you please provide the uncropped Google Ads UI screenshot showing this data and the complete request and response logs with the request ID and request header generated on your end?

Note that these logs can be requested or provided to the developer handling the Google Ads API transactions when logging of the API requests has been enabled. You may check here and click your client library for the specific guideline to enable it.

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

Regards,
Google Logo
Carmela
Google Ads API Team
 


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