Get reach estimate

668 views
Skip to first unread message

Quang Binh Dinh

unread,
Jul 8, 2022, 1:24:57 AM7/8/22
to Google Ads API and AdWords API Forum
I want to get reach estimate based on criteria like location, gender, age, keyword... currently I have taken reach from location, but reach from age and Gender is not possible. Can you guys help me out. Thanks a lot.

Here is my code:

$adGroupResourceName = ResourceNames::forAdGroup($customerId, $adGroupId);

        $keywordText = 'mars cruise';
        $campaignId = '17688751344';
        $locationId = 21167;

        // Creates a positive ad group criterion for gender.
        $genderAdGroupCriterion = new AdGroupCriterion([
            'ad_group' => $adGroupResourceName,
            // Targets male.
            'gender' => new GenderInfo(['type' => GenderType::UNDETERMINED])
        ]);

        // Creates a negative ad group criterion for age range.
        $ageRangeNegativeAdGroupCriterion = new AdGroupCriterion([
            'ad_group' => $adGroupResourceName,
            // Makes this ad group criterion negative.
            'negative' => true,
            // Targets the age range of 18 to 24.
            'age_range' => new AgeRangeInfo(['type' => AgeRangeType::AGE_RANGE_UNDETERMINED])
        ]);

        // Creates ad group criterion operations for both ad group criteria.
        $operations = [
            new AdGroupCriterionOperation(['create' => $genderAdGroupCriterion]),
            new AdGroupCriterionOperation(['create' => $ageRangeNegativeAdGroupCriterion])
        ];

        // Issues a mutate request to add the ad group criteria and print out some information.
        $adGroupCriterionServiceClient = $googleAdsClient->getAdGroupCriterionServiceClient();
        $response = $adGroupCriterionServiceClient->mutateAdGroupCriteria(
            $customerId,
            $operations
        );

        printf(
            "Added %d demographic ad group criteria:%s <br>",
            $response->getResults()->count(),
            PHP_EOL
        );

        foreach ($response->getResults() as $addedAdGroupCriterion) {
            /** @var AdGroupCriterion $addedAdGroupCriterion */
            // dd($addedAdGroupCriterion);
            print $addedAdGroupCriterion->getResourceName() . PHP_EOL;
        }

        $googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();
        // Creates a query that retrieves the targeting settings from a given ad group.

        $query = "SELECT ad_group_criterion.age_range.type, " .
                 "ad_group_criterion.gender.type, " .
                 "ad_group_criterion.keyword.text " .
                 "FROM ad_group_criterion " .
                 "WHERE " .
                 "ad_group_criterion.resource_name = '" . $response->getResults()[0]->getResourceName() . "'";

        // Issues a search request.
        $stream = $googleAdsServiceClient->searchStream($customerId, $query);
        $paged = $googleAdsServiceClient->search($customerId, $query);
        // $campaignBudget = self::createCampaignBudget($adWordsServices, $adWordsSession);

        $results = [];
        foreach($stream->iterateAllElements() as $googleAdsRow){
            $results[] = json_decode($googleAdsRow->serializeToJsonString(), true);
        }
        dd($results);

Google Ads API Forum Advisor

unread,
Jul 8, 2022, 2:50:36 AM7/8/22
to bin...@gmail.com, adwor...@googlegroups.com
Hi Quang,

Thank you for reaching out to us.

Moving forward, you could use the Forecast metrics in the API which is similar to the Keyword Planner in the UI. However, you will only be able to get the reach by location and keyword and not by age or gender. You can find more details here .

Moving forward, if this is currently available in the UI, you may provide our team with the full screenshot of it so we can further validate its availability in the API.

Best regards,
Google Logo
Heidi
Google Ads API Team
 


ref:_00D1U1174p._5004Q2cTr9i:ref

Quang Binh Dinh

unread,
Jul 8, 2022, 3:23:02 AM7/8/22
to Google Ads API and AdWords API Forum
Is it the "examples/Planning/ForecastReach.php" file?
https://github.com/googleads/google-ads-php/blob/986e0ead76e9d73950f5689474768497a501f592/examples/Planning/ForecastReach.php

When I execute, an error message appears like below:

ApiException was thrown with message '{
    "message": "The caller does not have permission",
    "code": 7,
    "status": "PERMISSION_DENIED",
    "details": [
        {
            "@type": "type.googleapis.com\/google.ads.googleads.v11.errors.GoogleAdsFailure",
            "errors": [
                {
                    "errorCode": {
                        "authorizationError": "ACTION_NOT_PERMITTED"
                    },
                    "message": "This request is not authorized to call ReachPlanningService. Developer Token not enabled: 8f8WLAItn3W8wWpmys_xxx",
                    "location": []
                }
            ],
            "requestId": "XOuaJSmDRyrmC5qrAyk8uw"
        }
    ]
}'.

It seems that my account doesn't have permission to call ReachPlanningService. How can I make the call. Thank you.

Google Ads API Forum Advisor

unread,
Jul 8, 2022, 10:10:07 AM7/8/22
to bin...@gmail.com, adwor...@googlegroups.com
Hi Quang,

Thank you for the reply. I work with Heid and allow me to assist you here. 
 
With regard to your concern, could you please confirm if you want ReachPlanService which enables media agencies and 3rd-party media planning software companies to accurately forecast the commercial reach of video campaigns on YouTube and Google Video Partners? If yes, then the code you are using is correct. However, if you want the Forecast metrics to get metrics for proposed or existing campaigns, ad groups, and keywords, including:
  • Impressions
  • Click through rate
  • Average cost per click
  • Clicks
  • Cost
Then, you should use this guide. Let me know if you have further questions. Please be aware that the ReachPlanService is available to allowlisted accounts only and that is why you encountered the ACTION_NOT_PERMITTED error. Please contact your Google representative if you need to be allowlisted. You can check here for the eligibility requirements.

Best regards,
Google Logo
Jinky
Google Ads API Team
 


ref:_00D1U1174p._5004Q2cTr9i:ref

Quang Binh Dinh

unread,
Jul 12, 2022, 7:04:08 AM7/12/22
to Google Ads API and AdWords API Forum
I executed "GetGeoTargetConstantsByNames.php" file to get reach metrics from location
https://github.com/googleads/google-ads-php/blob/986e0ead76e9d73950f5689474768497a501f592/examples/Targeting/GetGeoTargetConstantsByNames.php
But the reach estimate that I have, is not based on Keywords. In what code examples can I get reach metrics from Locations and Keywords?

Google Ads API Forum Advisor

unread,
Jul 12, 2022, 10:13:54 AM7/12/22
to bin...@gmail.com, adwor...@googlegroups.com
Hi Quang,

Thank you for getting back to us. To answer your question, you may refer to this Plan-level settings, it says here in API behavior "As of version v11 of the Google Ads API, KeywordPlan exposes only a forecast_period setting at the plan level. Other settings such as geo targets, network settings, and language targets are available only at the KeywordPlanCampaign level."

Quang Binh Dinh

unread,
Jul 13, 2022, 3:21:52 AM7/13/22
to Google Ads API and AdWords API Forum
In the example source code: https://github.com/googleads/google-ads-php/tree/986e0ead76e9d73950f5689474768497a501f592/examples
I don't see a connection between AddKeywordPlan (Planning/AddKeywordPlan.php) with ForecastReach (Planning/ForecastReach.php) or with GetGeoTargetConstantsByNames (Targeting/GetGeoTargetConstantsByNames.php) by KEYWORD_PLAN_ID ?

Google Ads API Forum Advisor

unread,
Jul 13, 2022, 6:52:02 AM7/13/22
to bin...@gmail.com, adwor...@googlegroups.com
Hi Quang,

Thank you for the reply. To have an accurate answer to this concern, could you please provide screenshot of the Google Ads UI where we can see this feature so we can check it better?

Quang Binh Dinh

unread,
Jul 13, 2022, 7:18:33 AM7/13/22
to Google Ads API and AdWords API Forum
I use the php sample code from here:
https://github.com/googleads/google-ads-php/tree/986e0ead76e9d73950f5689474768497a501f592/examples

I am using the functions in the files from the Planning and Target folder as mentioned above.

Screen Shot 2022-07-13 at 6.06.04 PM.png

I don't see a connection between AddKeywordPlan (Planning/AddKeywordPlan.php) with ForecastReach (Planning/ForecastReach.php) or with GetGeoTargetConstantsByNames (Targeting/GetGeoTargetConstantsByNames.php) by KEYWORD_PLAN_ID ?

Screen Shot 2022-07-13 at 6.10.45 PM.png

Screen Shot 2022-07-13 at 6.12.57 PM.png
(Planning/ForecastReach.php)

Screen Shot 2022-07-13 at 6.13.24 PM.png
(Targeting/GetGeoTargetConstantsByNames.php)

I don't see a KEYWORD_PLAN_ID declaration in (Planning/ForecastReach.php) or (Targeting/GetGeoTargetConstantsByNames.php).

So how do you get reach estimates from Location and Keyword?

Google Ads API Forum Advisor

unread,
Jul 13, 2022, 11:59:30 AM7/13/22
to bin...@gmail.com, adwor...@googlegroups.com
Hi Quang,

Thank you for getting back to our team and for providing additional details. 

Going back to your initial post "..currently I have taken reach from location, but reach from age and Gender is not possible.", if what you are indeed looking for is the reach forecasting feature, then you should be able to include them in your media plan.

After preparing your locations and supported criteria (keywords not included) as listed here, you may then proceed into this section. Once you have gathered the targeting settings and a product mix for your media plan, you can generate a curve

Also, you may take note that this is separate from forecast metrics feature - that generates forecasts based on your keyword plans instead of a media plan. Let us know if this is what you're looking for.

Best regards,

Google Logo
Peter Laurence
Google Ads API Team
 


ref:_00D1U1174p._5004Q2cTr9i:ref

Quang Binh Dinh

unread,
Jul 13, 2022, 11:39:39 PM7/13/22
to Google Ads API and AdWords API Forum
Screen Shot 2022-07-14 at 10.26.33 AM.png

As you replied "...However, you will only be able to get the reach by location and keyword and not by age or gender

I got the reach estimate from by location (you can see this example code: https://github.com/googleads/google-ads-php/blob/986e0ead76e9d73950f5689474768497a501f592/examples/Targeting/GetGeoTargetConstantsByNames.php) . But not estimated reach by Keyword. I want to get reach estimates from a combination of location and keyword.

Google Ads API Forum Advisor

unread,
Jul 14, 2022, 6:27:21 AM7/14/22
to bin...@gmail.com, adwor...@googlegroups.com
Hi Quang,

Thank you for the reply.

Please note that the Reach Forecasting is different from Generating Forecast Metrics.

Forecast metrics provide metrics for proposed or existing campaigns, ad groups, and keywords, including:
  • Impressions
  • Click through rate
  • Average cost per click
  • Clicks
  • Cost
Reach forecasting means that ReachPlanService enables media agencies and 3rd-party media planning software companies to accurately forecast the commercial reach of video campaigns on YouTube and Google Video Partners. This includes the Specifying a Media Plan. In this, (keywords not included) as listed here.

You may refer to the code example here if you will use Generating Forecast Metric s and may refer to this code example if you will use the Reach Forecasting.

Best regards,
Google Logo
Heidi
Google Ads API Team
 


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