เมตริกการคาดการณ์จะแสดง
เมตริกประสิทธิภาพโดยประมาณ (KeywordForecastMetrics) สำหรับ
แคมเปญที่เสนอหรือที่มีอยู่ เมตริกการคาดการณ์ที่พร้อมใช้งานจะขึ้นอยู่กับเวอร์ชัน API ที่รองรับและกลยุทธ์การเสนอราคา
- v24 ขึ้นไป:
clicks(การคลิก): แสดงผลเมื่อใช้ManualCpcBiddingStrategyหรือMaximizeClicksBiddingStrategyเท่านั้นcost_micros(ค่าใช้จ่าย): ค่าใช้จ่ายทั้งหมดที่คาดการณ์ไว้ในหน่วยไมโครaverage_cpc_micros(ต้นทุนต่อคลิกโดยเฉลี่ย): แสดงผลเมื่อใช้ManualCpcBiddingStrategyหรือMaximizeClicksBiddingStrategyและclicks > 0เท่านั้นconversions(Conversion): แสดงผลเมื่อใช้MaximizeConversionsBiddingStrategyเท่านั้นaverage_cpa_micros(ต้นทุนต่อการกระทำหนึ่งครั้งโดยเฉลี่ย): แสดงผลเมื่อ ใช้MaximizeConversionsBiddingStrategy(คำนวณเป็นcost_micros / conversions)
- v23 ลงไป:
- นอกเหนือจาก
clicks,cost_micros,average_cpc_micros,conversions, และaverage_cpa_micros(แสดงผลในกลยุทธ์การเสนอราคาทั้งหมด) แล้วKeywordForecastMetricsยัง แสดงผลimpressions(การแสดงผล),click_through_rate(อัตราการคลิกผ่าน) และconversion_rate(อัตรา Conversion) ด้วย
- นอกเหนือจาก
ทดสอบการกำหนดค่าแคมเปญต่างๆ เพื่อเพิ่มประสิทธิภาพเมตริกแต่ละรายการ การคาดการณ์ใช้ข้อมูล เช่น คะแนนคุณภาพและอัตราการคลิกผ่านที่ผ่านมา เพื่อจำลองประสิทธิภาพที่คาดหวัง
โดยปกติแล้ว เมตริกการคาดการณ์จะใช้หลังจากค้นพบคีย์เวิร์ดที่แนะนำด้วย ไอเดียคีย์เวิร์ด หรือกรองรายการคีย์เวิร์ดที่มีอยู่ด้วย เมตริกที่ผ่านมา และ เลือกจัดกลุ่มคีย์เวิร์ดเหล่านั้นตาม ธีมกลุ่มโฆษณา แม้ว่าเมตริกที่ผ่านมาจะจำกัดชุดคีย์เวิร์ดที่แนะนำจำนวนมากตามปริมาณการค้นหาที่ผ่านมา แต่เมตริกการคาดการณ์จะจำลองประสิทธิภาพในอนาคตเพื่อให้คุณเพิ่มประสิทธิภาพราคาเสนอ งบประมาณรายวัน และการกำหนดเป้าหมายก่อนที่จะอัปเดตแคมเปญที่แสดง
สร้างเมตริก
หากต้องการสร้างเมตริกการคาดการณ์ ให้ทำตามขั้นตอนต่อไปนี้
- สร้างออบเจ็กต์
CampaignToForecastที่แสดงถึง การกำหนดค่าแคมเปญ ออบเจ็กต์ForecastAdGroupและกลยุทธ์การเสนอราคาที่คุณต้องการประเมิน - เรียกใช้
KeywordPlanIdeaService.GenerateKeywordForecastMetricsด้วยCampaignToForecastและforecast_periodที่ไม่บังคับ (วันที่เริ่มต้นต้องเป็นอนาคต และวันที่สิ้นสุดภายใน 1 ปีนับจากวันนี้ หากละเว้น ระบบจะใช้ค่าเริ่มต้นเป็นวัน อาทิตย์หน้าถึงวันเสาร์ถัดไปในเขตเวลาของบัญชีลูกค้า) - อ่าน
KeywordForecastMetricsระดับแคมเปญจากฟิลด์campaign_forecast_metricsของGenerateKeywordForecastMetricsResponse
สร้างแคมเปญเพื่อคาดการณ์
เคล็ดลับบางประการเมื่อสร้างแคมเปญเพื่อคาดการณ์มีดังนี้
- สร้างกลุ่มโฆษณาตามธีม เช่น ความเกี่ยวข้องของครีเอทีฟโฆษณา หมวดหมู่ผลิตภัณฑ์ หรือต้นทุนต่อคลิก (หรือใช้คำแนะนำจาก
GenerateAdGroupThemes) - ใน v23 ลงไป ให้ใส่คีย์เวิร์ดเชิงลบทั่วไปโดยใช้
CampaignToForecast.negative_keywordsหรือForecastAdGroup.negative_keywords(เช่น หากคุณ ไม่ได้ทำงานด้านการสรรหาบุคลากร ให้ยกเว้นคีย์เวิร์ด'jobs') ใน v24 ขึ้นไป ระบบจะนำnegative_keywordsออก - ใช้บัญชีที่เกี่ยวข้องกับแคมเปญ อย่าคาดการณ์จากบัญชีที่ไม่เกี่ยวข้อง Google จะนำคะแนนคุณภาพและเนื้อหาครีเอทีฟโฆษณามาพิจารณาในการคาดการณ์
- หากแคมเปญไม่เกี่ยวข้องกับส่วนอื่นๆ ของบัญชี ให้ใช้บัญชีใหม่ที่สะอาดสำหรับการคาดการณ์
- ทำซ้ำการคาดการณ์ด้วยขอบเขตเวลาที่ต่างกันเพื่อให้ได้ภาพรวม
ความแตกต่างของเวอร์ชัน
ใน v24 ขึ้นไป CampaignToForecast ForecastAdGroup และ
KeywordForecastMetrics จะใช้สคีมาที่ปรับปรุงให้มีประสิทธิภาพมากขึ้นเมื่อเทียบกับ v23 ลงไป ดังที่แสดงในตารางต่อไปนี้
| ฟีเจอร์ | v24 ขึ้นไป | v23 ลงไป |
|---|---|---|
| คีย์เวิร์ดของกลุ่มโฆษณา | ForecastAdGroup.keywords (repeated KeywordInfo) |
ForecastAdGroup.biddable_keywords (repeated BiddableKeyword) |
| การกำหนดเป้าหมายตามสถานที่ | CampaignToForecast.geo_target_constants (ชื่อทรัพยากร repeated string) |
CampaignToForecast.geo_modifiers (repeated CriterionBidModifier ที่มีตัวคูณราคาเสนอที่ไม่บังคับ) |
| การกำหนดเป้าหมายในเครือข่าย Search | ไม่ได้ระบุไว้ใน CampaignToForecast (ค่าเริ่มต้นคือ Google Search) |
ที่จำเป็น CampaignToForecast.keyword_plan_network |
| คีย์เวิร์ดเชิงลบ | ไม่รองรับใน CampaignToForecast หรือ ForecastAdGroup |
รองรับโดยใช้ CampaignToForecast.negative_keywords และ ForecastAdGroup.negative_keywords |
| การลบล้างราคาเสนอ CPC ของกลุ่มโฆษณาและคีย์เวิร์ด | กำหนดค่าที่ระดับกลยุทธ์การเสนอราคาของแคมเปญเท่านั้น (ManualCpcBiddingStrategy.max_cpc_bid_micros หรือ MaximizeClicksBiddingStrategy.max_cpc_bid_ceiling_micros) |
สามารถลบล้างต่อกลุ่มโฆษณา (ForecastAdGroup.max_cpc_bid_micros) หรือต่อคีย์เวิร์ด (BiddableKeyword.max_cpc_bid_micros) ได้ด้วย |
| อัตรา Conversion ที่คาดหวังที่กำหนดเอง | ไม่รองรับใน CampaignToForecast |
ที่ไม่บังคับ CampaignToForecast.conversion_rate |
| เมตริกการคาดการณ์ที่แสดงผล | clicks และ average_cpc_micros (การเสนอราคา CPC ด้วยตนเองหรือเพิ่มจำนวนคลิกสูงสุดเท่านั้น), cost_micros, conversions และ average_cpa_micros (เพิ่มจำนวน Conversion สูงสุดเท่านั้น) |
แสดงผล clicks, cost_micros, average_cpc_micros, conversions และ average_cpa_micros ในกลยุทธ์การเสนอราคาทั้งหมด รวมถึง impressions, click_through_rate และ conversion_rate |
ตัวอย่างโค้ด
ตัวอย่างโค้ดถัดไปจะส่งคำขอไปยัง
KeywordPlanIdeaService.GenerateKeywordForecastMetrics โดยจะสร้าง CampaignToForecast แบบอินไลน์ที่มีกลุ่มโฆษณาและคีย์เวิร์ด แล้วแสดง campaign_forecast_metrics ที่แสดงผล
Java
private void runExample(GoogleAdsClient googleAdsClient, Long customerId) { CampaignToForecast campaignToForecast = createCampaignToForecast(googleAdsClient); GenerateKeywordForecastMetricsRequest request = GenerateKeywordForecastMetricsRequest.newBuilder() .setCustomerId(String.valueOf(customerId)) .setCampaign(campaignToForecast) .setForecastPeriod( DateRange.newBuilder() // Sets the forecast start date to tomorrow. .setStartDate(new DateTime().plusDays(1).toString("yyyy-MM-dd")) // Sets the forecast end date to 30 days from today. .setEndDate(new DateTime().plusDays(30).toString("yyyy-MM-dd"))) .build(); try (KeywordPlanIdeaServiceClient keywordPlanIdeaServiceClient = googleAdsClient.getLatestVersion().createKeywordPlanIdeaServiceClient()) { GenerateKeywordForecastMetricsResponse response = keywordPlanIdeaServiceClient.generateKeywordForecastMetrics(request); KeywordForecastMetrics metrics = response.getCampaignForecastMetrics(); System.out.printf( "Estimated daily clicks: %s%n", metrics.hasClicks() ? metrics.getClicks() : null); System.out.printf( "Estimated average CPC (micros): %s%n", metrics.hasAverageCpcMicros() ? metrics.getAverageCpcMicros() : null); } } /** * Creates the campaign to forecast. A campaign to forecast lets you try out various * configurations and keywords to find the best optimization for your future campaigns. Once * you've found the best campaign configuration, create a serving campaign in your Google Ads * account with similar values and keywords. For more details, see: * * <p>https://support.google.com/google-ads/answer/3022575 */ private CampaignToForecast createCampaignToForecast(GoogleAdsClient googleAdsClient) { CampaignToForecast.Builder campaignToForecastBuilder = CampaignToForecast.newBuilder() .setBiddingStrategy( CampaignBiddingStrategy.newBuilder() .setManualCpcBiddingStrategy( ManualCpcBiddingStrategy.newBuilder().setMaxCpcBidMicros(1_000_000L))); // See https://developers.google.com/google-ads/api/reference/data/geotargets for the list of // geo target IDs. Geo target constant 2840 is for USA. campaignToForecastBuilder.addGeoTargetConstants(ResourceNames.geoTargetConstant(2840)); // See https://developers.google.com/google-ads/api/reference/data/codes-formats#languages for // the list of language criteria IDs. Language constant 1000 is for English. campaignToForecastBuilder.addLanguageConstants(ResourceNames.languageConstant(1000)); // Create forecast ad group based on themes such as creative relevance, product category, or // cost per click. ForecastAdGroup.Builder forecastAdGroupBuilder = ForecastAdGroup.newBuilder(); forecastAdGroupBuilder.addKeywords( KeywordInfo.newBuilder() .setText("mars cruise") .setMatchType(KeywordMatchType.BROAD)); forecastAdGroupBuilder.addKeywords( KeywordInfo.newBuilder() .setText("cheap cruise") .setMatchType(KeywordMatchType.PHRASE)); forecastAdGroupBuilder.addKeywords( KeywordInfo.newBuilder() .setText("jupiter cruise") .setMatchType(KeywordMatchType.BROAD)); campaignToForecastBuilder.addAdGroups(forecastAdGroupBuilder.build()); return campaignToForecastBuilder.build(); }
C#
public void Run(GoogleAdsClient client, long customerId) { CampaignToForecast campaignToForecast = CreateCampaignToForecast(); KeywordPlanIdeaServiceClient keywordPlanIdeaService = client.GetService(Services.V26.KeywordPlanIdeaService); GenerateKeywordForecastMetricsRequest request = new GenerateKeywordForecastMetricsRequest() { CustomerId = customerId.ToString(), Campaign = campaignToForecast, ForecastPeriod = new DateRange() { // Set the forecast start date to tomorrow. StartDate = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"), // Set the forecast end date to 30 days from today. EndDate = DateTime.Now.AddDays(30).ToString("yyyy-MM-dd"), } }; try { GenerateKeywordForecastMetricsResponse response = keywordPlanIdeaService.GenerateKeywordForecastMetrics(request); KeywordForecastMetrics metrics = response.CampaignForecastMetrics; Console.WriteLine($"Estimated daily clicks: {metrics.Clicks}."); Console.WriteLine($"Estimated average cpc (micros): {metrics.AverageCpcMicros}."); } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } } /// <summary> /// Creates the campaign to forecast. A campaign to forecast lets you try out /// various configuration and keywords to find the best optimization for your /// future campaigns. Once you've found the best campaign configuration, /// create a serving campaign in your Google Ads account with similar values /// and keywords. For more details, see: /// https://support.google.com/google-ads/answer/3022575 /// </summary> private CampaignToForecast CreateCampaignToForecast() { CampaignToForecast campaignToForecast = new CampaignToForecast() { BiddingStrategy = new CampaignToForecast.Types.CampaignBiddingStrategy() { ManualCpcBiddingStrategy = new ManualCpcBiddingStrategy() { MaxCpcBidMicros = 1_000_000 } } }; // See https://developers.google.com/google-ads/api/reference/data/geotargets // for the list of geo target IDs. // Geo target constant 2840 is for USA. campaignToForecast.GeoTargetConstants.Add( ResourceNames.GeoTargetConstant(2840) ); // See https://developers.google.com/google-ads/api/reference/data/codes-formats#languages // for the list of language criteria IDs. // Language constant 1000 is for English. campaignToForecast.LanguageConstants.Add(ResourceNames.LanguageConstant(1000)); // Create forecast ad group based on themes such as creative relevance, product category, // or cost per click. ForecastAdGroup forecastAdGroup = new ForecastAdGroup(); KeywordInfo keyword1 = new KeywordInfo() { Text = "mars cruise", MatchType = KeywordMatchType.Broad }; forecastAdGroup.Keywords.Add(keyword1); KeywordInfo keyword2 = new KeywordInfo() { Text = "cheap cruise", MatchType = KeywordMatchType.Phrase }; forecastAdGroup.Keywords.Add(keyword2); KeywordInfo keyword3 = new KeywordInfo() { Text = "jupiter cruise", MatchType = KeywordMatchType.Exact }; forecastAdGroup.Keywords.Add(keyword3); campaignToForecast.AdGroups.Add(forecastAdGroup); return campaignToForecast; }
PHP
public static function runExample( GoogleAdsClient $googleAdsClient, int $customerId ): void { $campaignToForecast = self::createCampaignToForecast(); $keywordPlanIdeaServiceClient = $googleAdsClient->getKeywordPlanIdeaServiceClient(); // Generates keyword forecast metrics based on the specified parameters. $response = $keywordPlanIdeaServiceClient->generateKeywordForecastMetrics( new GenerateKeywordForecastMetricsRequest([ 'customer_id' => $customerId, 'campaign' => $campaignToForecast, 'forecast_period' => new DateRange([ // Sets the forecast start date to tomorrow. 'start_date' => date('Ymd', strtotime('+1 day')), // Sets the forecast end date to 30 days from today. 'end_date' => date('Ymd', strtotime('+30 days')) ]) ]) ); $metrics = $response->getCampaignForecastMetrics(); printf( "Estimated daily clicks: %s%s", $metrics->hasClicks() ? sprintf("%.2f", $metrics->getClicks()) : "'none'", PHP_EOL ); printf( "Estimated daily impressions: %s%s", $metrics->hasImpressions() ? sprintf("%.2f", $metrics->getImpressions()) : "'none'", PHP_EOL ); printf( "Estimated average CPC (micros): %s%s", $metrics->hasAverageCpcMicros() ? sprintf("%d", $metrics->getAverageCpcMicros()) : "'none'", PHP_EOL ); } /** * Creates the campaign to forecast. A campaign to forecast lets you try out various * configurations and keywords to find the best optimization for your future campaigns. Once * you've found the best campaign configuration, create a serving campaign in your Google Ads * account with similar values and keywords. For more details, see: * * https://support.google.com/google-ads/answer/3022575 * * @return CampaignToForecast the created campaign to forecast */ private static function createCampaignToForecast(): CampaignToForecast { // Creates a campaign to forecast. $campaignToForecast = new CampaignToForecast([ 'keyword_plan_network' => KeywordPlanNetwork::GOOGLE_SEARCH, 'bidding_strategy' => new CampaignBiddingStrategy([ 'manual_cpc_bidding_strategy' => new ManualCpcBiddingStrategy([ 'max_cpc_bid_micros' => 1_000_000 ]) ]), // See https://developers.google.com/google-ads/api/reference/data/geotargets for the // list of geo target IDs. 'geo_modifiers' => [ new CriterionBidModifier([ // Geo target constant 2840 is for USA. 'geo_target_constant' => ResourceNames::forGeoTargetConstant(2840) ]) ], // See // https://developers.google.com/google-ads/api/reference/data/codes-formats#languages // for the list of language criteria IDs. Language constant 1000 is for English. 'language_constants' => [ResourceNames::forLanguageConstant(1000)], ]); // Creates forecast ad group based on themes such as creative relevance, product category, // or cost per click. $forecastAdGroup = new ForecastAdGroup([ 'biddable_keywords' => [ new BiddableKeyword([ 'max_cpc_bid_micros' => 2_500_000, 'keyword' => new KeywordInfo([ 'text' => 'mars cruise', 'match_type' => KeywordMatchType::BROAD ]) ]), new BiddableKeyword([ 'max_cpc_bid_micros' => 1_500_000, 'keyword' => new KeywordInfo([ 'text' => 'cheap cruise', 'match_type' => KeywordMatchType::PHRASE ]) ]), new BiddableKeyword([ 'max_cpc_bid_micros' => 1_990_000, 'keyword' => new KeywordInfo([ 'text' => 'jupiter cruise', 'match_type' => KeywordMatchType::BROAD ]) ]) ], 'negative_keywords' => [ new KeywordInfo([ 'text' => 'moon walk', 'match_type' => KeywordMatchType::BROAD ]) ] ]); $campaignToForecast->setAdGroups([$forecastAdGroup]); return $campaignToForecast; }
Python
def main(client: GoogleAdsClient, customer_id: str): """The main method that creates all necessary entities for the example. Args: client: an initialized GoogleAdsClient instance. customer_id: a client customer ID. """ campaign_to_forecast: CampaignToForecast = create_campaign_to_forecast( client ) generate_forecast_metrics(client, customer_id, campaign_to_forecast) def create_campaign_to_forecast(client: GoogleAdsClient) -> CampaignToForecast: """Creates the campaign to forecast. A campaign to forecast lets you try out various configurations and keywords to find the best optimization for your future campaigns. Once you've found the best campaign configuration, create a serving campaign in your Google Ads account with similar values and keywords. For more details, see: https://support.google.com/google-ads/answer/3022575 Args: client: an initialized GoogleAdsClient instance. Returns: An CampaignToForecast instance. """ googleads_service: GoogleAdsServiceClient = client.get_service( "GoogleAdsService" ) # Create a campaign to forecast. campaign_to_forecast: CampaignToForecast = client.get_type( "CampaignToForecast" ) # Set the bidding strategy. campaign_to_forecast.bidding_strategy.manual_cpc_bidding_strategy.max_cpc_bid_micros = ( 1000000 ) # For the list of geo target IDs, see: # https://developers.google.com/google-ads/api/reference/data/geotargets # Geo target constant 2840 is for USA. campaign_to_forecast.geo_target_constants.append( googleads_service.geo_target_constant_path("2840") ) # For the list of language criteria IDs, see: # https://developers.google.com/google-ads/api/reference/data/codes-formats#languages # Language criteria 1000 is for English. campaign_to_forecast.language_constants.append( googleads_service.language_constant_path("1000") ) # Create forecast ad groups based on themes such as creative relevance, # product category, or cost per click. forecast_ad_group: ForecastAdGroup = client.get_type("ForecastAdGroup") # Create and configure three KeywordInfo instances. keyword_1: KeywordInfo = client.get_type("KeywordInfo") keyword_1.text = "mars cruise" keyword_1.match_type = client.enums.KeywordMatchTypeEnum.BROAD keyword_2: KeywordInfo = client.get_type("KeywordInfo") keyword_2.text = "cheap cruise" keyword_2.match_type = client.enums.KeywordMatchTypeEnum.PHRASE keyword_3: KeywordInfo = client.get_type("KeywordInfo") keyword_3.text = "cheap cruise" keyword_3.match_type = client.enums.KeywordMatchTypeEnum.EXACT # Add the keywords to the forecast ad group. forecast_ad_group.keywords.extend([keyword_1, keyword_2, keyword_3]) campaign_to_forecast.ad_groups.append(forecast_ad_group) return campaign_to_forecast def generate_forecast_metrics( client: GoogleAdsClient, customer_id: str, campaign_to_forecast: CampaignToForecast, ): """Generates forecast metrics and prints the results. Args: client: an initialized GoogleAdsClient instance. customer_id: a client customer ID. campaign_to_forecast: a CampaignToForecast to generate metrics for. """ keyword_plan_idea_service: KeywordPlanIdeaServiceClient = ( client.get_service("KeywordPlanIdeaService") ) request: GenerateKeywordForecastMetricsRequest = client.get_type( "GenerateKeywordForecastMetricsRequest" ) request.customer_id = customer_id request.campaign = campaign_to_forecast # Set the forecast range. Repeat forecasts with different horizons to get a # holistic picture. # Set the forecast start date to tomorrow. tomorrow = datetime.now() + timedelta(days=1) request.forecast_period.start_date = tomorrow.strftime("%Y-%m-%d") # Set the forecast end date to 30 days from today. thirty_days_from_now = datetime.now() + timedelta(days=30) request.forecast_period.end_date = thirty_days_from_now.strftime("%Y-%m-%d") response: GenerateKeywordForecastMetricsResponse = ( keyword_plan_idea_service.generate_keyword_forecast_metrics( request=request ) ) metrics = response.campaign_forecast_metrics print(f"Estimated daily clicks: {metrics.clicks}") print(f"Estimated daily average CPC: {metrics.average_cpc_micros}")
Ruby
def generate_forecast_metrics(customer_id) # GoogleAdsClient will read a config file from # ENV['HOME']/google_ads_config.rb when called without parameters client = Google::Ads::GoogleAds::GoogleAdsClient.new campaign_to_forecast = create_campaign_to_forecast(client) # Generates forecast metrics and prints the results. keyword_plan_idea_service = client.service.keyword_plan_idea # Set the forecast range. Repeat forecasts with different horizons to get a # holistic picture. forecast_period = client.resource.date_range do |p| tomorrow = Date.today + 1 p.start_date = tomorrow.strftime("%Y-%m-%d") # Set the forecast end date to 30 days from today. thirty_days_from_now = Date.today + 30 p.end_date = thirty_days_from_now.strftime("%Y-%m-%d") end response = keyword_plan_idea_service.generate_keyword_forecast_metrics( customer_id: customer_id, campaign: campaign_to_forecast, forecast_period: forecast_period, ) metrics = response.campaign_forecast_metrics puts "Estimated daily clicks: #{metrics.clicks}" puts "Estimated daily impressions: #{metrics.impressions}" puts "Estimated daily average CPC: #{metrics.average_cpc_micros}" end def create_campaign_to_forecast(client) campaign_to_forecast = client.resource.campaign_to_forecast do |c| c.keyword_plan_network = :GOOGLE_SEARCH c.bidding_strategy = client.resource.campaign_bidding_strategy do |bs| bs.manual_cpc_bidding_strategy = client.resource.manual_cpc_bidding_strategy do |mbs| mbs.max_cpc_bid_micros = 1000000 end end criterion_bid_modifier = client.resource.criterion_bid_modifier # For the list of geo target IDs, see: # https://developers.google.com/google-ads/api/reference/data/geotargets # Geo target constant 2840 is for USA. criterion_bid_modifier.geo_target_constant = client.path.geo_target_constant("2840") c.geo_modifiers << criterion_bid_modifier # For the list of language criteria IDs, see: # https://developers.google.com/google-ads/api/reference/data/codes-formats#languages # Language criteria 1000 is for English. language_constant = client.path.language_constant("1000") # English c.language_constants << language_constant # Create forecast ad groups based on themes such as creative relevance, # product category, or cost per click. forecast_ad_group = client.resource.forecast_ad_group biddable_keyword_1 = client.resource.biddable_keyword do |bk| bk.max_cpc_bid_micros = 1500000 bk.keyword = client.resource.keyword_info do |k| k.text = "mars cruise" k.match_type = :BROAD end end biddable_keyword_2 = client.resource.biddable_keyword do |bk| bk.max_cpc_bid_micros = 2500000 bk.keyword = client.resource.keyword_info do |k| k.text = "cheap cruise" k.match_type = :PHRASE end end biddable_keyword_3 = client.resource.biddable_keyword do |bk| bk.max_cpc_bid_micros = 1990000 bk.keyword = client.resource.keyword_info do |k| k.text = "cheap cruise" k.match_type = :EXACT end end forecast_ad_group.biddable_keywords << biddable_keyword_1 forecast_ad_group.biddable_keywords << biddable_keyword_2 forecast_ad_group.biddable_keywords << biddable_keyword_3 # Create and configure a negative keyword, then add it to the forecast ad # group. negative_keyword = client.resource.keyword_info do |k| k.text = "moon walk" k.match_type = :BROAD end forecast_ad_group.negative_keywords << negative_keyword c.ad_groups << forecast_ad_group end return campaign_to_forecast end
Perl
sub generate_forecast_metrics { my ($api_client, $customer_id) = @_; my $campaign_to_forecast = create_campaign_to_forecast(); my $keyword_forecast_metrics_response = $api_client->KeywordPlanIdeaService()->generate_keyword_forecast_metrics({ customerId => $customer_id, campaign => $campaign_to_forecast, # Set the forecast range. Repeat forecasts with different horizons # to get a holistic picture. forecastPeriod => Google::Ads::GoogleAds::V26::Common::DateRange->new({ # Set the forecast start date to tomorrow. startDate => strftime("%Y-%m-%d", localtime(time + 60 * 60 * 24)), # Set the forecast end date to 30 days from today. endDate => strftime("%Y-%m-%d", localtime(time + 60 * 60 * 24 * 30))}) }); my $metrics = $keyword_forecast_metrics_response->{campaignForecastMetrics}; printf "Estimated daily clicks: %s.\n", defined $metrics->{clicks} ? $metrics->{clicks} : "undef"; printf "Estimated average cpc (micros): %s.\n\n", defined $metrics->{averageCpcMicros} ? $metrics->{averageCpcMicros} : "undef"; return 1; } # Creates the campaign to forecast. A campaign to forecast lets you try out # various configuration and keywords to find the best optimization for your # future campaigns. Once you've found the best campaign configuration, # create a serving campaign in your Google Ads account with similar values # and keywords. For more details, see: # https://support.google.com/google-ads/answer/3022575 sub create_campaign_to_forecast { my ($api_client) = @_; # Create a campaign to forecast. my $campaign_to_forecast = Google::Ads::GoogleAds::V26::Services::KeywordPlanIdeaService::CampaignToForecast ->new(); # Set the bidding strategy. $campaign_to_forecast->{biddingStrategy}->{manualCpcBiddingStrategy} = Google::Ads::GoogleAds::V26::Services::KeywordPlanIdeaService::ManualCpcBiddingStrategy ->new({maxCpcBidMicros => 1000000}); # See https://developers.google.com/google-ads/api/reference/data/geotargets # for the list of geo target IDs. # Geo target constant 2840 is for USA. $campaign_to_forecast->{geoTargetConstants} = [ Google::Ads::GoogleAds::V26::Utils::ResourceNames::geo_target_constant( 2840)]; # See https://developers.google.com/google-ads/api/reference/data/codes-formats#languages # for the list of language criteria IDs. $campaign_to_forecast->{languageConstants} = [ # Language criteria 1000 is for English. Google::Ads::GoogleAds::V26::Utils::ResourceNames::language_constant(1000)]; # Create forecast ad groups based on themes such as creative relevance, # product category, or cost per click. $campaign_to_forecast->{adGroups} = [ Google::Ads::GoogleAds::V26::Services::KeywordPlanIdeaService::ForecastAdGroup ->new({ keywords => [ Google::Ads::GoogleAds::V26::Common::KeywordInfo->new({ text => "mars cruise", matchType => 'BROAD' } ), Google::Ads::GoogleAds::V26::Common::KeywordInfo->new({ text => "cheap cruise", matchType => 'PHRASE' } ), Google::Ads::GoogleAds::V26::Common::KeywordInfo->new({ text => "jupiter cruise", matchType => 'EXACT' })]})]; return $campaign_to_forecast; }
curl
การจับคู่กับ UI
ตารางต่อไปนี้จะจับคู่
KeywordPlanIdeaService.GenerateKeywordForecastMetrics
พารามิเตอร์กับเครื่องมือวางแผนคีย์เวิร์ดใน UI ของ Google Ads
| เครื่องมือวางแผนคีย์เวิร์ดใน UI | Google Ads API |
|---|---|
| ป้อนคีย์เวิร์ด |
|
| สถานที่ตั้ง |
|
| ภาษา | CampaignToForecast.language_constants |
| งบประมาณรายวัน | |
| ราคาเสนอ CPC | |
| ช่วงวันที่ | GenerateKeywordForecastMetricsRequest.forecast_period |