소개
이 가이드에서는 예측 Manager API를 사용할 수 있습니다.
트래픽 예측
트래픽 예측을 사용하면 다음을 수행할 수 있습니다. 향후 노출 기회와 함께 이전 트래픽을 읽고 더 나은 결과를 도출합니다. 인벤토리를 분류하고 패키징하는 방법을 알아봅니다.
자바
// Create the date range. Include the previous and next 7 days. Interval interval = new Interval( Instant.now().plus(Duration.standardDays(-7)), Instant.now().plus(Duration.standardDays(7))); DateRange dateRange = new DateRange(); dateRange.setStartDate(DateTimes.toDateTime(interval.getStart()).getDate()); dateRange.setEndDate(DateTimes.toDateTime(interval.getEnd()).getDate()); // Request the traffic data. TrafficDataRequest trafficDataRequest = new TrafficDataRequest(); trafficDataRequest.setRequestedDateRange(dateRange); trafficDataRequest.setTargeting(targeting); TrafficDataResponse trafficData = forecastService.getTrafficData(trafficDataRequest);
Python
# Create a start date that's 7 days in the past and an end date that's 7 days # in the future. today = datetime.date.today() start_date = today - datetime.timedelta(days=7) end_date = today + datetime.timedelta(days=7) # Create targeting. targeting = { 'inventoryTargeting': { 'targetedAdUnits': [ { 'includeDescendants': True, 'adUnitId': root_ad_unit_id, } ] } } # Request the traffic forecast data. traffic_data = forecast_service.getTrafficData({ 'targeting': targeting, 'requestedDateRange': { 'startDate': start_date, 'endDate': end_date } })
PHP
// Create the date range. Include the previous and next 7 days. $startDate = AdManagerDateTimes::fromDateTime(new DateTime('-7 day')) ->getDate(); $endDate = AdManagerDateTimes::fromDateTime(new DateTime('+7 day')) ->getDate(); $dateRange = new DateRange(); $dateRange->setStartDate($startDate); $dateRange->setEndDate($endDate); // Request the traffic forecast data. $trafficDataRequest = new TrafficDataRequest(); $trafficDataRequest->setRequestedDateRange($dateRange); $trafficDataRequest->setTargeting($targeting); $trafficData = $forecastService->getTrafficData($trafficDataRequest);
C#
TrafficDataRequest trafficDataRequest = new TrafficDataRequest() { requestedDateRange = new DateRange() { startDate = DateTimeUtilities.FromDateTime(startDate, "America/New_York").date, endDate = DateTimeUtilities.FromDateTime(endDate, "America/New_York").date }, targeting = new Targeting() { inventoryTargeting = new InventoryTargeting() { targetedAdUnits = new AdUnitTargeting[] { new AdUnitTargeting() { adUnitId = rootAdUnitId, includeDescendants = true } } } } }; TrafficDataResponse trafficData = forecastService.getTrafficData(trafficDataRequest);
Ruby
# Create a start date that's 7 days in the past and an end date that's 7 days # in the future. today = ad_manager.today start_date = today - 7 end_date = today + 7 # Create targeting. targeting = { :inventory_targeting => { :targeted_ad_units => [ { :include_descendants => true, :ad_unit_id => root_ad_unit_id } ] } } # Request the traffic forecast data. traffic_data = forecast_service.get_traffic_data({ :targeting => targeting, :requested_date_range => { :start_date => start_date.to_h, :end_date => end_date.to_h } })
가용성 예측
AvailabilityForecast 사용할 수 있는 최대 단위 수를 보고합니다. 지정할 수 있습니다. 이 예측은 시스템의 인벤토리 기능을 살펴보겠습니다
예측에는 사용 가능, 일치, 가능, 게재 완료, 예약됨이 포함됩니다. 단위. 또한 모든 경합 광고 항목 및 사용 가능한 단위도 포함할 수 있습니다. 각 타겟팅마다 분류 에 설정된 옵션에 따라 AvailabilityForecastOptions 기본적으로 둘 다 예측에 포함되지 않습니다.
타겟팅 분류에는 각 타겟팅에 일치하는 단위와 사용 가능한 단위가 포함됩니다. 있습니다. 이러한 분류 항목은 광고 항목 타겟팅입니다. 예를 들어 광고 단위 ID 123456에 타겟팅된 광고 항목이 있습니다. 다음과 유사한 분류가 포함됩니다.
<targetingCriteriaBreakdowns> <targetingDimension>AD_UNIT</targetingDimension> <targetingCriteriaId>123456</targetingCriteriaId> <targetingCriteriaName>My Ad Unit Name</targetingCriteriaName> <excluded>false</excluded> <availableUnits>1000</availableUnits> <matchedUnits>2300</matchedUnits> </targetingCriteriaBreakdowns>
기존 또는 예상 회선에서 가용성 예측을 실행할 수 있습니다. 있습니다.
기존 광고 항목
ID를 사용하여 기존 광고 항목에 대한 가용성 예측을 실행할 수 있습니다.
자바
// Get the ForecastService. ForecastServiceInterface forecastService = adManagerServices.get(session, ForecastServiceInterface.class); // Get forecast for line item. AvailabilityForecastOptions options = new AvailabilityForecastOptions(); options.setIncludeContendingLineItems(true); options.setIncludeTargetingCriteriaBreakdown(true); AvailabilityForecast forecast = forecastService.getAvailabilityForecastById(lineItemId, options); long matched = forecast.getMatchedUnits(); double availablePercent = (forecast.getAvailableUnits() / (matched * 1.0)) * 100; String unitType = forecast.getUnitType().toString().toLowerCase(); System.out.printf("%d %s matched.%n", matched, unitType); System.out.printf("%.2f%% %s available.%n", availablePercent, unitType); if (forecast.getPossibleUnits() != null) { double possiblePercent = (forecast.getPossibleUnits() / (matched * 1.0)) * 100; System.out.printf("%.2f%% %s possible.%n", possiblePercent, unitType); } System.out.printf( "%d contending line items.%n", forecast.getContendingLineItems() == null ? 0 : forecast.getContendingLineItems().length);
Python
# Initialize appropriate service. forecast_service = client.GetService('ForecastService', version='v202408') # Set forecasting options. forecast_options = { 'includeContendingLineItems': True, 'includeTargetingCriteriaBreakdown': True, } # Get forecast for line item. forecast = forecast_service.getAvailabilityForecastById( line_item_id, forecast_options) matched = int(forecast['matchedUnits']) available_units = int(forecast['availableUnits']) if matched > 0: available_percent = (float(available_units) / matched) * 100. else: available_percent = 0 contending_line_items = getattr(forecast, 'contentingLineItems', []) # Display results. print('%s %s matched.' % (matched, forecast['unitType'].lower())) print('%s%% %s available.' % ( available_percent, forecast['unitType'].lower())) print('%d contending line items.' % len(contending_line_items)) if 'possibleUnits' in forecast and matched: possible_percent = (int(forecast['possibleUnits'])/float(matched)) * 100. print('%s%% %s possible' % (possible_percent, forecast['unitType'].lower()))
PHP
$forecastService = $serviceFactory->createForecastService($session); // Get forecast for line item. $options = new AvailabilityForecastOptions(); $options->setIncludeContendingLineItems(true); $options->setIncludeTargetingCriteriaBreakdown(true); $forecast = $forecastService->getAvailabilityForecastById( $lineItemId, $options ); // Print out forecast results. $matchedUnits = $forecast->getMatchedUnits(); $unitType = strtolower($forecast->getUnitType()); printf("%d %s matched.%s", $matchedUnits, $unitType, PHP_EOL); if ($matchedUnits > 0) { $availableUnits = $forecast->getAvailableUnits(); $percentAvailableUnits = $availableUnits / $matchedUnits * 100; $possibleUnits = $forecast->getPossibleUnits(); $percentPossibleUnits = $possibleUnits / $matchedUnits * 100; printf( "%.2d%% %s available.%s", $percentAvailableUnits, $unitType, PHP_EOL ); printf( "%.2d%% %s possible.%s", $percentPossibleUnits, $unitType, PHP_EOL ); } printf( "%d contending line items.%s", count($forecast->getContendingLineItems()), PHP_EOL );
C#
using (ForecastService forecastService = user.GetService<ForecastService>()) { // Get forecast for line item. AvailabilityForecastOptions options = new AvailabilityForecastOptions(); options.includeContendingLineItems = true; options.includeTargetingCriteriaBreakdown = true; AvailabilityForecast forecast = forecastService.getAvailabilityForecastById(lineItemId, options); // Display results. long matched = forecast.matchedUnits; double availablePercent = (double) (forecast.availableUnits / (matched * 1.0)) * 100; String unitType = forecast.unitType.ToString().ToLower(); Console.WriteLine("{0} {1} matched.\n{2} % {3} available.", matched, unitType, availablePercent, unitType); if (forecast.possibleUnitsSpecified) { double possiblePercent = (double) (forecast.possibleUnits / (matched * 1.0)) * 100; Console.WriteLine(possiblePercent + "% " + unitType + " possible.\n"); } Console.WriteLine("{0} contending line items.", (forecast.contendingLineItems != null) ? forecast.contendingLineItems.Length : 0);
Ruby
# Get the ForecastService. forecast_service = ad_manager.service(:ForecastService, API_VERSION) # Set forecasting options. forecast_options = { :include_contending_line_items => True, :include_targeting_criteria_breakdown => True, } # Get forecast for the line item. forecast = forecast_service.get_availability_forecast_by_id( line_item_id, forecast_options ) unless forecast.nil? # Display results. matched = forecast[:matched_units] available_percent = forecast[:available_units] * 100.0 / matched unit_type = forecast[:unit_type].to_s.downcase puts '%.2f %s matched.' % [matched, unit_type] puts '%.2f%% of %s available.' % [available_percent, unit_type] puts '%d contending line items.' % forecast[:contending_line_items].size unless forecast[:possible_units].nil? possible_percent = forecast[:possible_units] * 100.0 / matched puts '%.2f%% of %s possible.' % [possible_percent, unit_type] end end
이 예의 출력은 다음과 유사합니다.
100 clicks matched.
2 contending line items.
잠재고객 광고 항목
또는 예상 광고 항목 및 예측을 유지할 수 있습니다. 이렇게 하려면 로컬 광고 항목 객체를 인스턴스화하고 ProspectiveLineItem 형식을 사용합니다. 광고주 ID를 설정하면 예측에서 통합 차단 규칙을 고려합니다.
자바
// Get forecast for prospective line item. ProspectiveLineItem prospectiveLineItem = new ProspectiveLineItem(); prospectiveLineItem.setAdvertiserId(advertiserId); prospectiveLineItem.setLineItem(lineItem); AvailabilityForecastOptions options = new AvailabilityForecastOptions(); options.setIncludeContendingLineItems(true); options.setIncludeTargetingCriteriaBreakdown(true); AvailabilityForecast forecast = forecastService.getAvailabilityForecast(prospectiveLineItem, options);
Python
prospective_line_item = { 'lineItem': line_item, 'advertiserId': advertiser_id } # Set forecasting options. forecast_options = { 'includeContendingLineItems': True, # The field includeTargetingCriteriaBreakdown can only be set if # breakdowns are not manually specified. # 'includeTargetingCriteriaBreakdown': True, 'breakdown': { 'timeWindows': [ now_datetime, now_datetime + datetime.timedelta(days=1), now_datetime + datetime.timedelta(days=2), now_datetime + datetime.timedelta(days=3), now_datetime + datetime.timedelta(days=4), end_datetime ], 'targets': [ { # Optional, the name field is only used to identify this # breakdown in the response. 'name': 'United States', 'targeting': { 'inventoryTargeting': { 'targetedAdUnits': [ { 'includeDescendants': True, 'adUnitId': root_ad_unit_id, } ] }, 'geoTargeting': { 'targetedLocations': [ { 'id': '2840', 'displayName': 'US' } ] } } }, { # Optional, the name field is only used to identify this # breakdown in the response. 'name': 'Geneva', 'targeting': { 'inventoryTargeting': { 'targetedAdUnits': [ { 'includeDescendants': True, 'adUnitId': root_ad_unit_id, } ] }, 'geoTargeting': { 'targetedLocations': [ { 'id': '20133', 'displayName': 'Geneva' } ] } } } ] } } # Get forecast. forecast = forecast_service.getAvailabilityForecast( prospective_line_item, forecast_options)
PHP
// Get forecast for prospective line item. $prospectiveLineItem = new ProspectiveLineItem(); $prospectiveLineItem->setAdvertiserId($advertiserId); $prospectiveLineItem->setLineItem($lineItem); $options = new AvailabilityForecastOptions(); $options->setIncludeContendingLineItems(true); $options->setIncludeTargetingCriteriaBreakdown(true); $forecast = $forecastService->getAvailabilityForecast( $prospectiveLineItem, $options );
C#
// Get availability forecast. AvailabilityForecastOptions options = new AvailabilityForecastOptions() { includeContendingLineItems = true, // Targeting criteria breakdown can only be included if breakdowns // are not speficied. includeTargetingCriteriaBreakdown = false, breakdown = new ForecastBreakdownOptions { timeWindows = new DateTime[] { lineItem.startDateTime, DateTimeUtilities.FromDateTime(tomorrow.AddDays(1), "America/New_York"), DateTimeUtilities.FromDateTime(tomorrow.AddDays(2), "America/New_York"), DateTimeUtilities.FromDateTime(tomorrow.AddDays(3), "America/New_York"), DateTimeUtilities.FromDateTime(tomorrow.AddDays(4), "America/New_York"), lineItem.endDateTime }, targets = new ForecastBreakdownTarget[] { new ForecastBreakdownTarget() { // Optional name field to identify this breakdown // in the response. name = "United States", targeting = new Targeting() { inventoryTargeting = new InventoryTargeting() { targetedAdUnits = new AdUnitTargeting[] { new AdUnitTargeting() { adUnitId = rootAdUnitId, includeDescendants = true } } }, geoTargeting = new GeoTargeting() { targetedLocations = new Location[] { new Location() { id = 2840L } } } } }, new ForecastBreakdownTarget() { // Optional name field to identify this breakdown // in the response. name = "Geneva", targeting = new Targeting() { inventoryTargeting = new InventoryTargeting() { targetedAdUnits = new AdUnitTargeting[] { new AdUnitTargeting() { adUnitId = rootAdUnitId, includeDescendants = true } } }, geoTargeting = new GeoTargeting() { targetedLocations = new Location[] { new Location () { id = 20133L } } } } } } } }; ProspectiveLineItem prospectiveLineItem = new ProspectiveLineItem() { advertiserId = advertiserId, lineItem = lineItem }; AvailabilityForecast forecast = forecastService.getAvailabilityForecast(prospectiveLineItem, options);
Ruby
prospective_line_item = { :advertiser_id => advertiser_id, :line_item => line_item } # Set forecasting options. forecast_options = { :include_contending_line_items => true, # The field includeTargetingCriteriaBreakdown can only be set if breakdowns # are not mannually specified. # :include_targeting_criteria_breakdown => true, :breakdown => { # Break down forecast by day from start_time to end_time :time_windows => time_windows, # Break down forecast by any targeting configuration :targets => [ { # Optional, the name field is only used to identify this breakdown in # the response. :name => 'United States', :targeting => { :inventory_targeting => targeting[:inventory_targeting], :geo_targeting => { :targeted_locations => [ { :id => '2840', :display_name => 'US' } ] } } }, { # Optional, the name field is only used to identify this breakdown in # the response. :name => 'Geneva', :targeting => { :inventory_targeting => targeting[:inventory_targeting], :geo_targeting => { :targeted_locations => [ { :id => '20133', :display_name => 'Geneva' } ] } } } ] } } # Get forecast for the line item. forecast = forecast_service.get_availability_forecast( prospective_line_item, forecast_options)
게재 예측
여러 경쟁 광고 항목의 게재를 시뮬레이션하려면 다음과 같이 DeliveryForecast.
기존 광고 항목
ID를 사용하여 기존 광고 항목의 게재 예측을 실행할 수 있습니다.
자바
// Get the ForecastService. ForecastServiceInterface forecastService = adManagerServices.get(session, ForecastServiceInterface.class); DeliveryForecastOptions options = new DeliveryForecastOptions(); DeliveryForecast forecast = forecastService.getDeliveryForecastByIds(Longs.toArray(lineItemIds), options); for (LineItemDeliveryForecast lineItemForecast : forecast.getLineItemDeliveryForecasts()) { String unitType = lineItemForecast.getUnitType().toString().toLowerCase(); System.out.printf("Forecast for line item %d:%n", lineItemForecast.getLineItemId()); System.out.printf("\t%d %s matched%n", lineItemForecast.getMatchedUnits(), unitType); System.out.printf("\t%d %s delivered%n", lineItemForecast.getDeliveredUnits(), unitType); System.out.printf( "\t%d %s predicted%n", lineItemForecast.getPredictedDeliveryUnits(), unitType); }
Python
# Initialize appropriate service. forecast_service = client.GetService('ForecastService', version='v202408') # Get forecast for line item. forecast = forecast_service.getDeliveryForecastByIds( [line_item_id1, line_item_id2], {'ignoredLineItemIds': []}) for single_forecast in forecast['lineItemDeliveryForecasts']: unit_type = single_forecast['unitType'] print('Forecast for line item %d:\n\t%d %s matched\n\t%d %s delivered\n\t' '%d %s predicted\n' % ( single_forecast['lineItemId'], single_forecast['matchedUnits'], unit_type, single_forecast['deliveredUnits'], unit_type, single_forecast['predictedDeliveryUnits'], unit_type)) if __name__ == '__main__': # Initialize client object. ad_manager_client = ad_manager.AdManagerClient.LoadFromStorage() main(ad_manager_client, LINE_ITEM_ID_1, LINE_ITEM_ID_2)
PHP
$forecastService = $serviceFactory->createForecastService($session); // Get forecast for the line items with no options set. $forecast = $forecastService->getDeliveryForecastByIds( [$lineItemId1, $lineItemId2], new DeliveryForecastOptions() ); // Print out forecast results. $lineItemDeliveryForecasts = $forecast->getLineItemDeliveryForecasts(); foreach ($lineItemDeliveryForecasts as $lineItemForecast) { $unitType = strtolower($lineItemForecast->getUnitType()); printf( "Forecast for line item ID %d:%s", $lineItemForecast->getLineItemId(), PHP_EOL ); printf( " %d %s matched%s", $lineItemForecast->getMatchedUnits(), $unitType, PHP_EOL ); printf( " %d %s delivered%s", $lineItemForecast->getDeliveredUnits(), $unitType, PHP_EOL ); printf( " %d %s predicted%s", $lineItemForecast->getPredictedDeliveryUnits(), $unitType, PHP_EOL ); }
C#
using (ForecastService forecastService = user.GetService<ForecastService>()) { // Get a delivery forecast for the line items. DeliveryForecastOptions options = new DeliveryForecastOptions(); options.ignoredLineItemIds = new long[] { }; DeliveryForecast forecast = forecastService.getDeliveryForecastByIds(new long[] { lineItemId1, lineItemId2 }, options); // Display results. foreach (LineItemDeliveryForecast lineItemForecast in forecast .lineItemDeliveryForecasts) { String unitType = lineItemForecast.unitType.GetType().Name.ToLower(); Console.WriteLine("Forecast for line item {0}:", lineItemForecast.lineItemId); Console.WriteLine("\t{0} {1} matched", lineItemForecast.matchedUnits, unitType); Console.WriteLine("\t{0} {1} delivered", lineItemForecast.deliveredUnits, unitType); Console.WriteLine("\t{0} {1} predicted", lineItemForecast.predictedDeliveryUnits, unitType); }
Ruby
# Get the ForecastService. forecast_service = ad_manager.service(:ForecastService, API_VERSION) # Get forecast for the line item. forecast = forecast_service.get_delivery_forecast_by_ids( [line_item_id1, line_item_id2], nil) unless forecast.nil? || forecast[:line_item_delivery_forecasts].nil? forecast[:line_item_delivery_forecasts].each do |single_forecast| # Display results. unit_type = single_forecast[:unit_type] puts ('Forecast for line item %d:\n\t%d %s matched\n\t%d %s ' + 'delivered\n\t%d %s predicted\n') % [single_forecast[:line_item_id], single_forecast[:matched_units], unit_type, single_forecast[:delivered_units], unit_type, single_forecast[:predicted_delivery_units], unit_type] end end
이 예의 출력은 다음과 유사합니다.
Forecast for line item 14678:
100 clicks matched
0 clicks delivered
98 clicks predicted
게재 시뮬레이션에서 광고 항목을 제외하려는 경우 ID를 설정하여 DeliveryForecastOptions.
잠재고객 광고 항목
가용성 예측과 마찬가지로 게재 예측을 온라인으로 실행할 수 있습니다. 유지되지 않는 항목을 찾습니다. 이렇게 하려면 ForecastService.getDeliveryForecast 메서드를 사용하여 축소하도록 요청합니다.
향후 판매율 보고서
향후 판매율 보고서 인벤토리의 사용 가능 여부를 Google Ad Manager 네트워크를 통해 수익을 극대화하고 모든 인벤토리를 판매율입니다. 향후 판매율 보고서는 ReportService에 대한 요청 메시지입니다.
FAQ
- 가용성을 예측하려는 광고 항목이 많이 있습니다. 하나의 요청에서 여러 예측을 실행할 수 있나요?
- 아니요. 각 줄에 대해 별도의 가용성 예측을 요청해야 합니다. 예상 광고 항목도 있습니다
- 여러 차례 예측을 실행한 결과 현재 EXCEEDED_QUOTA개의 오류가 발생합니다. 어떻게 된 일인가요?
- 예측은 계산 비용이 많이 들고 할당량 시스템은 서비스가 안정적임을 고려해야 합니다 결과 예측을 안전하게 기다렸다가 재시도할 수 있습니다. 할당량 오류 발생
- NO_FORECAST_YET 또는 NOT_ENOUGH_INVENTORY 오류의 원인은 무엇인가요? 네트워크 트래픽을 기반으로
- 예측이 실행됩니다. 기록을 참조하세요. 이전 데이터가 충분하지 않아 예측을 실행할 수 없는 경우도 있습니다. 자세한 내용은 자세히 알아보려면 ForecastError 문서를 참조하세요.
- AlternativeUnitTypeForecast란 무엇인가요?
- 사용 가능한 다른 인벤토리를 아는 것이 유용할 때도 있습니다. 대상 예를 들어 CPC 항목 item, 대체 단위 유형 예측 노출수에 대한 정보가 포함됩니다.
- Ad Manager 예측과 관련하여 일반적인 질문이 더 있습니다.
- 제품 보증이 적용되는지 확인 FAQ를 확인하거나 개발자에게 문의하세요. 포럼에서 확인할 수 있습니다.