估算流量

AdWords API 的 TrafficEstimatorService 可用来获取所提议的或现有的广告系列、广告组和关键字的流量估算值,包括以下估算统计数据:

  • 平均每次点击费用
  • 平均排名
  • 点击率
  • 每日点击次数
  • 每日展示次数
  • 总费用

可使用不同的广告系列条件、投放网络设置、每日预算和最高每次点击费用,对提议的广告系列广告组进行模拟。

您还可以通过提供相应的 campaignIdadGroupId 来获取现有广告系列或广告组的流量估算值。

使用案例

在制作新的广告系列和广告组或修改现有广告系列时,您可以使用 TrafficEstimatorService 来估算未来的流量,并帮助您确定所提议的关键字(和设置)是否为最佳。例如,如果所选关键字的点击率较低,您可能需要重新考虑是否要使用该关键字。

您还可以使用 TrafficEstimatorService 获取与 AdWords 关键字规划师获取点击和费用的效果预测值功能类似的信息。

此外,还可以使用 TargetingIdeaService 为广告组提供更多关键字提示。运用这些新的关键字提示之前,请使用 TrafficEstimatorService 对这些新关键字的效果进行估算。有关其他信息,请参阅生成定位提示指南。

获取流量估算值

TrafficEstimatorService 的主要输入是 TrafficEstimatorSelector

要获取流量估算值,必须通过设置 CampaignEstimateRequestAdGroupEstimateRequest 指定现有广告系列和广告组,或者配置所提议的广告系列和广告组。

AdGroupEstimateRequest 内,您还必须为要估算流量的关键字指定 KeywordEstimateRequest

以下各节通过一个例子展示了利用 TrafficEstimatorService 获取流量估算值的具体步骤。

准备请求

您需要自下而上构建 TrafficEstimatorSelector。要创建完整的请求,应该遵循以下构建顺序:

  1. KeywordEstimateRequest
  2. AdGroupEstimateRequest
  3. CampaignEstimateRequest

首先,需要构建 KeywordEstimateRequest。通常需要对多个关键字进行估算,而每个关键字都应该有相应的 KeywordEstimateRequest

Java

List<Keyword> keywords = new ArrayList<Keyword>();

Keyword marsCruiseKeyword = new Keyword();
marsCruiseKeyword.setText("mars cruise");
marsCruiseKeyword.setMatchType(KeywordMatchType.BROAD);
keywords.add(marsCruiseKeyword);

Keyword cheapCruiseKeyword = new Keyword();
cheapCruiseKeyword.setText("cheap cruise");
cheapCruiseKeyword.setMatchType(KeywordMatchType.PHRASE);
keywords.add(cheapCruiseKeyword);

Keyword cruiseKeyword = new Keyword();
cruiseKeyword.setText("cruise");
cruiseKeyword.setMatchType(KeywordMatchType.EXACT);
keywords.add(cruiseKeyword);

// Create a keyword estimate request for each keyword.
List<KeywordEstimateRequest> keywordEstimateRequests = new ArrayList<KeywordEstimateRequest>();
for (Keyword keyword : keywords) {
  KeywordEstimateRequest keywordEstimateRequest = new KeywordEstimateRequest();
  keywordEstimateRequest.setKeyword(keyword);
  keywordEstimateRequests.add(keywordEstimateRequest);
}

// Add a negative keyword to the traffic estimate.
KeywordEstimateRequest negativeKeywordEstimateRequest = new KeywordEstimateRequest();
negativeKeywordEstimateRequest.setKeyword(new Keyword(null, null, null, "hiking tour",
    KeywordMatchType.BROAD));
negativeKeywordEstimateRequest.setIsNegative(true);
keywordEstimateRequests.add(negativeKeywordEstimateRequest);
    

.NET

Keyword keyword1 = new Keyword();
keyword1.text = "mars cruise";
keyword1.matchType = KeywordMatchType.BROAD;

Keyword keyword2 = new Keyword();
keyword2.text = "cheap cruise";
keyword2.matchType = KeywordMatchType.PHRASE;

Keyword keyword3 = new Keyword();
keyword3.text = "cruise";
keyword3.matchType = KeywordMatchType.EXACT;

Keyword[] keywords = new Keyword[] { keyword1, keyword2, keyword3 };

// Create a keyword estimate request for each keyword.
List<KeywordEstimateRequest> keywordEstimateRequests = new List<KeywordEstimateRequest>();

foreach (Keyword keyword in keywords) {
  KeywordEstimateRequest keywordEstimateRequest = new KeywordEstimateRequest();
  keywordEstimateRequest.keyword = keyword;
  keywordEstimateRequests.Add(keywordEstimateRequest);
}

// Create negative keywords.
Keyword negativeKeyword1 = new Keyword();
negativeKeyword1.text = "moon walk";
negativeKeyword1.matchType = KeywordMatchType.BROAD;

KeywordEstimateRequest negativeKeywordEstimateRequest = new KeywordEstimateRequest();
negativeKeywordEstimateRequest.keyword = negativeKeyword1;
negativeKeywordEstimateRequest.isNegative = true;
keywordEstimateRequests.Add(negativeKeywordEstimateRequest);
    

Python

keywords = [
    {'text': 'mars cruise', 'matchType': 'BROAD'},
    {'text': 'cheap cruise', 'matchType': 'PHRASE'},
    {'text': 'cruise', 'matchType': 'EXACT'}
]
negative_keywords = [
    {'text': 'moon walk', 'matchType': 'BROAD'}
]
keyword_estimate_requests = []
for keyword in keywords:
  keyword_estimate_requests.append({
      'keyword': {
          'xsi_type': 'Keyword',
          'matchType': keyword['matchType'],
          'text': keyword['text']
      }
  })

for keyword in negative_keywords:
  keyword_estimate_requests.append({
      'keyword': {
          'xsi_type': 'Keyword',
          'matchType': keyword['matchType'],
          'text': keyword['text']
      },
      'isNegative': 'true'
  })
    

PHP

// Create keywords. Up to 2000 keywords can be passed in a single request.
$keywords = array();
$keywords[] = new Keyword('mars cruise', 'BROAD');
$keywords[] = new Keyword('cheap cruise', 'PHRASE');
$keywords[] = new Keyword('cruise', 'EXACT');

// Create a keyword estimate request for each keyword.
$keywordEstimateRequests = array();
foreach ($keywords as $keyword) {
  $keywordEstimateRequest = new KeywordEstimateRequest();
  $keywordEstimateRequest->keyword = $keyword;
  $keywordEstimateRequests[] = $keywordEstimateRequest;
}

// Negative keywords don't return estimates, but adjust the estimates of the
// other keywords in the hypothetical ad group.
$negativeKeywords = array();
$negativeKeywords[] = new Keyword('moon walk', 'BROAD');

// Create a keyword estimate request for each negative keyword.
foreach ($negativeKeywords as $negativeKeyword) {
  $keywordEstimateRequest = new KeywordEstimateRequest();
  $keywordEstimateRequest->keyword = $negativeKeyword;
  $keywordEstimateRequest->isNegative = true;
  $keywordEstimateRequests[] = $keywordEstimateRequest;
}
    

Perl

# Create keywords. Refer to the TrafficEstimatorService documentation for
# the maximum number of keywords that can be passed in a single request.
# https://developers.google.com/adwords/api/docs/reference/latest/TrafficEstimatorService
my @keywords = (
  Google::Ads::AdWords::v201609::Keyword->new({
      text      => "mars cruise",
      matchType => "BROAD"
    }
  ),
  Google::Ads::AdWords::v201609::Keyword->new({
      text      => "cheap cruise",
      matchType => "PHRASE"
    }
  ),
  Google::Ads::AdWords::v201609::Keyword->new({
      text      => "cruise",
      matchType => "EXACT"
    }));

my @negative_keywords = (
  Google::Ads::AdWords::v201609::Keyword->new({
      text      => "moon walk",
      matchType => "BROAD"
    }));

# Create a keyword estimate request for each keyword.
my @keyword_estimate_requests;
foreach my $keyword (@keywords) {
  push @keyword_estimate_requests,
    Google::Ads::AdWords::v201609::KeywordEstimateRequest->new(
    {keyword => $keyword,});
}
foreach my $keyword (@negative_keywords) {
  push @keyword_estimate_requests,
    Google::Ads::AdWords::v201609::KeywordEstimateRequest->new({
      keyword    => $keyword,
      isNegative => 1
    });
}
    

Ruby

# Create keywords. Up to 2000 keywords can be passed in a single request.
keywords = [
    # The 'xsi_type' field allows you to specify the xsi:type of the object
    # being created. It's only necessary when you must provide an explicit
    # type that the client library can't infer.
  {:xsi_type => 'Keyword', :text => 'mars cruise', :match_type => 'BROAD'},
  {:xsi_type => 'Keyword', :text => 'cheap cruise', :match_type => 'PHRASE'},
  {:xsi_type => 'Keyword', :text => 'cruise', :match_type => 'EXACT'},
  {:xsi_type => 'Keyword', :text => 'moon walk', :match_type => 'BROAD'}
]

# Create a keyword estimate request for each keyword.
keyword_requests = keywords.map {|keyword| {:keyword => keyword}}

# Negative keywords don't return estimates, but adjust the estimates of the
# other keywords in the hypothetical ad group. To specify a negative keyword
# set the is_negative field to true.
keyword_requests[3][:is_negative] = true
    

发送到 TrafficEstimatorService 的关键字列表中的关键字既可能已存在于关键字分类中,也可能是从 TargetingIdeaService 获取的新关键字。

下一步是构建 AdGroupEstimateRequest。与关键字列表类似,可以对多个广告组进行估算。本示例只对一个广告组进行了估算:

Java

// Create ad group estimate requests.
List<AdGroupEstimateRequest> adGroupEstimateRequests = new ArrayList<AdGroupEstimateRequest>();
AdGroupEstimateRequest adGroupEstimateRequest = new AdGroupEstimateRequest();
adGroupEstimateRequest.setKeywordEstimateRequests(keywordEstimateRequests
    .toArray(new KeywordEstimateRequest[] {}));
adGroupEstimateRequest.setMaxCpc(new Money(null, 1000000L));
adGroupEstimateRequests.add(adGroupEstimateRequest);
    

.NET

// Create ad group estimate requests.
AdGroupEstimateRequest adGroupEstimateRequest = new AdGroupEstimateRequest();
adGroupEstimateRequest.keywordEstimateRequests = keywordEstimateRequests.ToArray();
adGroupEstimateRequest.maxCpc = new Money();
adGroupEstimateRequest.maxCpc.microAmount = 1000000;
    

Python

# Create ad group estimate requests.
adgroup_estimate_requests = [{
    'keywordEstimateRequests': keyword_estimate_requests,
    'maxCpc': {
        'xsi_type': 'Money',
        'microAmount': '1000000'
    }
}]
    

PHP

// Create ad group estimate requests.
$adGroupEstimateRequest = new AdGroupEstimateRequest();
$adGroupEstimateRequest->keywordEstimateRequests = $keywordEstimateRequests;
$adGroupEstimateRequest->maxCpc = new Money(1000000);
    

Perl

# Create ad group estimate requests.
my $ad_group_estimate_request =
  Google::Ads::AdWords::v201609::AdGroupEstimateRequest->new({
    keywordEstimateRequests => \@keyword_estimate_requests,
    maxCpc =>
      Google::Ads::AdWords::v201609::Money->new({microAmount => 1000000})});
    

Ruby

# Create ad group estimate requests.
ad_group_request = {
    :keyword_estimate_requests => keyword_requests,
    :max_cpc => {
        :micro_amount => 1000000
    }
}
    

下一步,构建 CampaignEstimateRequest。为获得更准确的结果,构建 CampaignEstimateRequest 时还应该设置地理位置和语言等其他广告系列条件。您还可以在 CampaignEstimateRequestAdGroupEstimateRequest 中指定现有广告系列 ID 和广告组 ID,以允许该服务加载历史数据。

Java

// Create campaign estimate requests.
List<CampaignEstimateRequest> campaignEstimateRequests =
    new ArrayList<CampaignEstimateRequest>();
CampaignEstimateRequest campaignEstimateRequest = new CampaignEstimateRequest();
campaignEstimateRequest.setAdGroupEstimateRequests(adGroupEstimateRequests
    .toArray(new AdGroupEstimateRequest[] {}));

Location unitedStates = new Location();
unitedStates.setId(2840L);
Language english = new Language();
english.setId(1000L);
campaignEstimateRequest.setCriteria(new Criterion[] {unitedStates, english});
campaignEstimateRequests.add(campaignEstimateRequest);
    

.NET

// Create campaign estimate requests.
CampaignEstimateRequest campaignEstimateRequest = new CampaignEstimateRequest();
campaignEstimateRequest.adGroupEstimateRequests = new AdGroupEstimateRequest[] {
    adGroupEstimateRequest};

// Optional: Set additional criteria for filtering estimates.
// See http://code.google.com/apis/adwords/docs/appendix/countrycodes.html
// for a detailed list of country codes.
Location countryCriterion = new Location();
countryCriterion.id = 2840; //US

// See http://code.google.com/apis/adwords/docs/appendix/languagecodes.html
// for a detailed list of language codes.
Language languageCriterion = new Language();
languageCriterion.id = 1000; //en

campaignEstimateRequest.criteria = new Criterion[] { countryCriterion, languageCriterion };
    

Python

# Create campaign estimate requests.
campaign_estimate_requests = [{
    'adGroupEstimateRequests': adgroup_estimate_requests,
    'criteria': [
        {
            'xsi_type': 'Location',
            'id': '2840'  # United States.
        },
        {
            'xsi_type': 'Language',
            'id': '1000'  # English.
        }
    ],
}]
    

PHP

// Create campaign estimate requests.
$campaignEstimateRequest = new CampaignEstimateRequest();
$campaignEstimateRequest->adGroupEstimateRequests[] = $adGroupEstimateRequest;

// Optional: Set additional criteria for filtering estimates.
// See http://code.google.com/apis/adwords/docs/appendix/countrycodes.html
// for a detailed list of country codes.
// Set targeting criteria. Only locations and languages are supported.
$unitedStates = new Location();
$unitedStates->id = 2840;
$campaignEstimateRequest->criteria[] = $unitedStates;

// See http://code.google.com/apis/adwords/docs/appendix/languagecodes.html
// for a detailed list of language codes.
$english = new Language();
$english->id = 1000;
$campaignEstimateRequest->criteria[] = $english;
    

Perl

my $location = Google::Ads::AdWords::v201609::Location->new({
    id => "2840"    # US - see http://goo.gl/rlrFr
});
my $language = Google::Ads::AdWords::v201609::Language->new({
    id => "1000"    # en - see http://goo.gl/LvMmS
});

# Create campaign estimate requests.
my $campaign_estimate_request =
  Google::Ads::AdWords::v201609::CampaignEstimateRequest->new({
    adGroupEstimateRequests => [$ad_group_estimate_request],
    criteria                => [$location, $language]});
    

Ruby

# Create campaign estimate requests.
campaign_request = {
    :ad_group_estimate_requests => [ad_group_request],
    # Set targeting criteria. Only locations and languages are supported.
    :criteria => [
        {:xsi_type => 'Location', :id => 2840}, # United States
        {:xsi_type => 'Language', :id => 1000}  # English
    ]
}
    

最后,配置 TrafficEstimatorSelector。然后,您可以通过 get() 操作进行发送,获取封装在 TrafficEstimatorResult 对象中的流量估算值。从 v201605 开始,可以使用 platformEstimateRequested 属性请求按平台细分的广告系列级估算值列表。

Java

// Create selector.
TrafficEstimatorSelector selector = new TrafficEstimatorSelector();
selector.setCampaignEstimateRequests(campaignEstimateRequests
    .toArray(new CampaignEstimateRequest[] {}));

// Optional: Request a list of campaign level estimates segmented by platform.
selector.setPlatformEstimateRequested(true);

// Get traffic estimates.
TrafficEstimatorResult result = trafficEstimatorService.get(selector);
    

.NET

// Create the selector.
TrafficEstimatorSelector selector = new TrafficEstimatorSelector() {
  campaignEstimateRequests = new CampaignEstimateRequest[] { campaignEstimateRequest },

  // Optional: Request a list of campaign level estimates segmented by platform.
  platformEstimateRequested = true
};

// Get traffic estimates.
TrafficEstimatorResult result = trafficEstimatorService.get(selector);
    

Python

# Create the selector.
selector = {
    'campaignEstimateRequests': campaign_estimate_requests,
}

# Optional: Request a list of campaign-level estimates segmented by
# platform.
selector['platformEstimateRequested'] = True

# Get traffic estimates.
estimates = traffic_estimator_service.get(selector)
    

PHP

// Create selector.
$selector = new TrafficEstimatorSelector();
$selector->campaignEstimateRequests[] = $campaignEstimateRequest;

// Optional: Request a list of campaign level estimates segmented by platform.
$selector->platformEstimateRequested = true;

// Make the get request.
$result = $trafficEstimatorService->get($selector);
    

Perl

# Optional: Request a list of campaign level estimates segmented by platform.
my $platform_estimate_request = "1";

# Create selector.
my $selector = Google::Ads::AdWords::v201609::TrafficEstimatorSelector->new({
    campaignEstimateRequests  => [$campaign_estimate_request],
    platformEstimateRequested => [$platform_estimate_request]});

# Get traffic estimates.
my $result = $client->TrafficEstimatorService()->get({selector => $selector});
    

Ruby

# Create a selector.
selector = {
  :campaign_estimate_requests => [campaign_request],
  # Optional: Request a list of campaign level estimates segmented by
  # platform.
  :platform_estimate_requested => true
}

# Execute the request.
response = traffic_estimator_srv.get(selector)
    

处理响应

选择器中的每个 CampaignEstimateRequest 对象在 TrafficEstimatorResult 中生成相应的 CampaignEstimate 对象。类似地,每个 AdGroupEstimateRequest 对象都在结果中有对应的 AdGroupEstimate 对象。如果您请求按平台细分的广告系列级估算值,将通过 CampaignEstimate 对象的 platformEstimates 属性提供这些结果。

Java

// Display traffic estimates.
if (result != null
    && result.getCampaignEstimates() != null
    && result.getCampaignEstimates().length > 0) {
  CampaignEstimate campaignEstimate = result.getCampaignEstimates()[0];

  // Display the campaign level estimates segmented by platform.
  if (campaignEstimate.getPlatformEstimates() != null) {
    for (PlatformCampaignEstimate platformEstimate : campaignEstimate.getPlatformEstimates()) {
      String platformMessage =
          String.format(
              "Results for the platform with ID %d and name '%s':%n",
              platformEstimate.getPlatform().getId(),
              platformEstimate.getPlatform().getPlatformName());
      displayMeanEstimates(
          platformMessage,
          platformEstimate.getMinEstimate(),
          platformEstimate.getMaxEstimate());
    }
  }

  // Display the keyword estimates.
  KeywordEstimate[] keywordEstimates =
      campaignEstimate.getAdGroupEstimates()[0].getKeywordEstimates();
  for (int i = 0; i < keywordEstimates.length; i++) {
    if (Boolean.TRUE.equals(keywordEstimateRequests.get(i).getIsNegative())) {
      continue;
    }

    Keyword keyword = keywordEstimateRequests.get(i).getKeyword();
    KeywordEstimate keywordEstimate = keywordEstimates[i];

    String keywordMessage =
        String.format(
            "Results for the keyword with text '%s' and match type '%s':%n",
            keyword.getText(), keyword.getMatchType());
    displayMeanEstimates(keywordMessage, keywordEstimate.getMin(), keywordEstimate.getMax());
  }
} else {
  System.out.println("No traffic estimates were returned.");
}
    

.NET

// Display traffic estimates.
if (result != null && result.campaignEstimates != null &&
    result.campaignEstimates.Length > 0) {
  CampaignEstimate campaignEstimate = result.campaignEstimates[0];

  // Display the campaign level estimates segmented by platform.
  if (campaignEstimate.platformEstimates != null) {
    foreach (PlatformCampaignEstimate platformEstimate in
        campaignEstimate.platformEstimates) {
      string platformMessage = string.Format("Results for the platform with ID: " +
          "{0} and name : {1}.", platformEstimate.platform.id,
          platformEstimate.platform.platformName);

      DisplayMeanEstimates(platformMessage, platformEstimate.minEstimate,
          platformEstimate.maxEstimate);
    }
  }

  // Display the keyword estimates.
  if (campaignEstimate.adGroupEstimates != null &&
      campaignEstimate.adGroupEstimates.Length > 0) {
    AdGroupEstimate adGroupEstimate = campaignEstimate.adGroupEstimates[0];

    if (adGroupEstimate.keywordEstimates != null) {
      for (int i = 0; i < adGroupEstimate.keywordEstimates.Length; i++) {
        Keyword keyword = keywordEstimateRequests[i].keyword;
        KeywordEstimate keywordEstimate = adGroupEstimate.keywordEstimates[i];

        if (keywordEstimateRequests[i].isNegative) {
          continue;
        }
        string kwdMessage = string.Format("Results for the keyword with text = '{0}' " +
            "and match type = '{1}':", keyword.text, keyword.matchType);
        DisplayMeanEstimates(kwdMessage, keywordEstimate.min, keywordEstimate.max);
      }
    }
  }
} else {
  Console.WriteLine("No traffic estimates were returned.");
}
    

Python

campaign_estimate = estimates['campaignEstimates'][0]

# Display the campaign level estimates segmented by platform.
if 'platformEstimates' in campaign_estimate:
  platform_template = ('Results for the platform with ID: "%d" and name: '
                       '"%s".')
  for platform_estimate in campaign_estimate['platformEstimates']:
    platform = platform_estimate['platform']
    DisplayEstimate(platform_template % (platform['id'],
                                         platform['platformName']),
                    platform_estimate['minEstimate'],
                    platform_estimate['maxEstimate'])

# Display the keyword estimates.
if 'adGroupEstimates' in campaign_estimate:
  ad_group_estimate = campaign_estimate['adGroupEstimates'][0]
  if 'keywordEstimates' in ad_group_estimate:
    keyword_estimates = ad_group_estimate['keywordEstimates']
    keyword_template = ('Results for the keyword with text "%s" and match '
                        'type "%s":')

    keyword_estimates_and_requests = zip(keyword_estimates,
                                         keyword_estimate_requests)

    for keyword_tuple in keyword_estimates_and_requests:
      if keyword_tuple[1].get('isNegative', False):
        continue
      keyword = keyword_tuple[1]['keyword']
      keyword_estimate = keyword_tuple[0]
      DisplayEstimate(keyword_template % (keyword['text'],
                                          keyword['matchType']),
                      keyword_estimate['min'], keyword_estimate['max'])
    

PHP

// Display results.
$platformEstimates = $result->campaignEstimates[0]->platformEstimates;
if ($platformEstimates !== null) {
  foreach ($platformEstimates as $platformEstimate) {
    if ($platformEstimate->minEstimate !== null
        && $platformEstimate->maxEstimate !== null) {
      printf(
          "Results for the platform with ID %d and name '%s':\n",
          $platformEstimate->platform->id,
          $platformEstimate->platform->platformName
      );
      printMeanEstimate($platformEstimate->minEstimate,
          $platformEstimate->maxEstimate);
    }
  }
}

$keywordEstimates =
    $result->campaignEstimates[0]->adGroupEstimates[0]->keywordEstimates;
for ($i = 0; $i < sizeof($keywordEstimates); $i++) {
  $keywordEstimateRequest = $keywordEstimateRequests[$i];
  // Skip negative keywords, since they don't return estimates.
  if (!$keywordEstimateRequest->isNegative) {
    $keyword = $keywordEstimateRequest->keyword;
    $keywordEstimate = $keywordEstimates[$i];

    if ($keywordEstimate->min !== null && $keywordEstimate->max !== null) {
      // Print the mean of the min and max values.
      printf("Results for the keyword with text '%s' and match type '%s':\n",
          $keyword->text, $keyword->matchType);
      printMeanEstimate($keywordEstimate->min, $keywordEstimate->max);
    }
  }
}
    

Perl

# Display traffic estimates.
if ($result) {
  my $campaign_estimates = $result->get_campaignEstimates();
  if ($campaign_estimates) {
    # Display the campaign level estimates segmented by platform.
    foreach my $campaign_estimate (@{$campaign_estimates}) {
      if ($campaign_estimate->get_platformEstimates()) {
        foreach
          my $platform_estimate (@{$campaign_estimate->get_platformEstimates()})
        {
          my $platform_message = sprintf(
            "Results for the platform with ID: %d and name : %s",
            $platform_estimate->get_platform()->get_id(),
            $platform_estimate->get_platform()->get_platformName());
          display_mean_estimates(
            $platform_message,
            $platform_estimate->get_minEstimate(),
            $platform_estimate->get_maxEstimate());
        }
      }

      if ($campaign_estimate->get_adGroupEstimates()) {
        my $keyword_estimates =
          $campaign_estimate->get_adGroupEstimates()->[0]
          ->get_keywordEstimates();
        for (my $i = 0 ; $i < scalar(@{$keyword_estimates}) ; $i++) {
          # Negative keywords don't generate estimates but instead affect
          # estimates of your other keywords, the following condition just
          # skips printing out estimates for a negative keyword.
          if ($keyword_estimate_requests[$i]->get_isNegative()) {
            next;
          }

          my $keyword = $keyword_estimate_requests[$i]->get_keyword();
          my $keyword_estimate = $keyword_estimates->[$i];
          my $keyword_message =
            sprintf
            "Results for the keyword with text '%s' and match type '%s':\n",
            $keyword->get_text(), $keyword->get_matchType();
          display_mean_estimates(
            $keyword_message,
            $keyword_estimate->get_min(),
            $keyword_estimate->get_max());
        }
      }
    }
  }
    

Ruby

# Display traffic estimates.
if response and response[:campaign_estimates] and
    response[:campaign_estimates].size > 0
  campaign_estimate = response[:campaign_estimates].first

  unless campaign_estimate[:platform_estimates].nil?
    # Display the campaign level estimates segmented by platform.
    campaign_estimate[:platform_estimates].each do |platform_estimate|
      platform_message = ('Results for the platform with ID %d and name ' +
          '"%s":') % [platform_estimate[:platform][:id],
          platform_estimate[:platform][:platform_name]]
      display_mean_estimates(
          platform_message,
          platform_estimate[:min_estimate],
          platform_estimate[:max_estimate]
      )
    end
  end

  # Display the keyword estimates.
  keyword_estimates =
      campaign_estimate[:ad_group_estimates].first[:keyword_estimates]
  keyword_estimates.each_with_index do |keyword_estimate, index|
    next if keyword_requests[index][:is_negative]
    keyword = keyword_requests[index][:keyword]

    keyword_message = ('Results for the keyword with text "%s" and match ' +
        'type "%s":') % [keyword[:text], keyword[:match_type]]
    display_mean_estimates(
        keyword_message,
        keyword_estimate[:min],
        keyword_estimate[:max]
    )
  end
else
  puts 'No traffic estimates were returned.'
end
    

最重要同时也是最有意思的结果对象是 AdGroupEstimate 中对应的 KeywordEstimate 对象。它包含每个关键字流量估算值 (StatsEstimate) 的下限 (min) 和上限 (max)。

一定要记住:返回的值是估算值,不保证实际效果值一定能落在这些边界内。

计算总转化次数估算值

API 不会像关键字规划师那样直接提供估算的总转化价值,但您可以根据提供的统计数据计算出一个结果:

Estimated total conversions = Estimated clicks * Historical conversion rate
Estimated total conversion value = Estimated total conversions * Conversion value

与关键字规划师的对照

TrafficEstimatorService 的使用方法与 AdWords 关键字规划师的获取点击和费用的效果预测值功能的使用方法类似。

要使用 TrafficEstimatorService 进行此操作,您需要指定已经存在的广告系列,或创建一个包含广告组和关键字的模拟广告系列:

关键字规划师 AdWords API
输入关键字 KeywordEstimateRequest
定位 - 地理位置 CampaignEstimateRequest.criteria 中使用地理位置条件
定位语言 CampaignEstimateRequest.criteria 中使用语言条件
定位 - 投放网络 CampaignEstimateRequest.networkSetting
日期范围 不支持

在关键字规划师中可以指定每日预算和出价金额。在 AdWords API 中,dailyBudgetCampaignEstimateRequest 的组成部分,而称为 maxCpc 的出价金额可以在 AdGroupEstimateRequestKeywordEstimateRequest 中设置。这些都必须在请求时指定;因此,即使它们已出现在关键字规划师的结果屏幕上,使用 API 的时候,也必须将它们包含在请求中。

完整代码示例

每个客户端库都在优化文件夹中包含了一个完整代码示例:

发送以下问题的反馈:

此网页
AdWords API
AdWords API
需要帮助?请访问我们的支持页面