Buat Resource

Item baris memiliki banyak resource induk yang setelan dan penargetannya diwarisi oleh item baris tersebut. Sebagian besar resource ini dapat dibuat, diambil, dan diperbarui menggunakan Display & Video 360 API. Halaman ini menjelaskan hierarki resource dan memberikan contoh cara membuat resource ini menggunakan Display & Video 360 API.

Hierarki Resource

Diagram hierarki resource

Di Display & Video 360, ada hierarki resource yang setelannya diperhitungkan dalam penayangan iklan. Setiap resource memiliki tujuan yang berbeda dalam penayangan iklan. Mulai dari tingkat hierarki terendah:

  • Item Baris adalah resource yang mengontrol iklan mana yang ditayangkan, kapan iklan tersebut ditayangkan, dan kepada siapa iklan tersebut ditayangkan.
    • Item baris YouTube & Partners juga memiliki referensi turunan Grup Iklan dan Ads. Iklan ini memberikan tingkat penargetan tambahan di bawah anggaran item baris tunggal. Item baris YouTube & Partners , Grup Iklan, Iklan, dan penargetannya tidak dapat diedit menggunakan API.
  • Perjanjian pemasangan iklan berisi beberapa item baris. Nilai default diberikan untuk pengaturan item baris yang tidak ada.
  • Kampanye berisi beberapa pesanan pemasangan iklan. Mereka tidak memberlakukan setelan pada perjanjian pemasangan iklan mereka. Setelannya berfungsi sebagai framing yang digunakan untuk mengukur progres dan keberhasilan iklan yang ditayangkan.
  • Pengiklan memiliki beberapa kampanye iklan. Aturan ini menerapkan penargetan keamanan merek dan setelan umum lainnya pada iklan yang ditayangkan di bawahnya. Objek iklan tersebut juga memiliki objek materi iklan yang digunakan dalam iklan yang ditayangkan di bawahnya dan memberikan akses ke resource yang digunakan dalam penargetan.
  • Partner memiliki beberapa pengiklan. Aturan ini menerapkan penargetan keamanan merek lebih lanjut dan setelan lain pada pengiklan tersebut. Solusi ini juga memberikan akses ke resource yang digunakan dalam aktivitas penargetan dan Floodlight yang digunakan dalam tracking konversi. Partner tidak dapat diedit melalui API.

Inheritance

Item baris mewarisi banyak setelan dan akses dari resource induknya. Saat mengelola item baris dan penayangan iklan, kualitas yang diwariskan yang perlu dipertimbangkan mencakup:

  • Materi iklan dan aktivitas Floodlight yang tersedia: Item baris hanya memiliki akses ke resource yang dimiliki oleh partner induk atau pengiklan mereka. Materi iklan dibuat di bagian pengiklan dan aktivitas Floodlight dimiliki oleh partner. Resource yang ditetapkan ke kolom resource LineItem creativeIds dan conversionCounting masing-masing harus memiliki pengiklan induk dan partner yang sama.
  • Entitas yang dapat diakses dan dapat ditargetkan: Resource seperti saluran, audiens gabungan, dan lainnya digunakan dalam penargetan. Item baris hanya dapat ditargetkan menggunakan resource yang dapat diakses oleh partner induknya atau pengiklan.
  • Penargetan keamanan merek: Item baris mewarisi penargetan yang ditetapkan di tingkat partner dan pengiklan. Penargetan yang diwarisi tidak dapat dihapus. Penargetan yang ada ini dapat diidentifikasi dengan kolom inheritance opsi penargetan yang ditetapkan dan akan memengaruhi penargetan lebih lanjut yang dapat diterapkan.

Buat Resource

Semua resource yang tercantum di atas dapat dikelola menggunakan Display & Video 360 API. Berikut adalah contoh kode sederhana tentang cara membuat setiap resource ini menggunakan library klien yang disediakan.

Membuat pengiklan

Berikut contoh cara membuat pengiklan:

Java

// Create an advertiser object.
Advertiser advertiser = new Advertiser();
advertiser.setPartnerId(partner-id);
advertiser.setDisplayName(display-name);
advertiser.setEntityStatus("ENTITY_STATUS_ACTIVE");

// Create and set the advertiser general configuration.
AdvertiserGeneralConfig advertiserGeneralConfig = new AdvertiserGeneralConfig();
advertiserGeneralConfig.setDomainUrl(domain-url);
advertiserGeneralConfig.setCurrencyCode("USD");
advertiser.setGeneralConfig(advertiserGeneralConfig);

// Create the ad server configuration structure.
AdvertiserAdServerConfig advertiserAdServerConfig = new AdvertiserAdServerConfig();

// Create and add the third party only configuration to the ad server
// configuration.
advertiserAdServerConfig.setThirdPartyOnlyConfig(new ThirdPartyOnlyConfig());

// Set the ad server configuration.
advertiser.setAdServerConfig(advertiserAdServerConfig);

// Create and set the creative configuration.
advertiser.setCreativeConfig(new AdvertiserCreativeConfig());

// Create and set the billing configuration.
AdvertiserBillingConfig advertiserBillingConfig = new AdvertiserBillingConfig();
advertiserBillingConfig.setBillingProfileId(billing-profile-id);
advertiser.setBillingConfig(advertiserBillingConfig);

// Configure the create request.
Advertisers.Create request = service.advertisers().create(advertiser);

// Create the advertiser.
Advertiser response = request.execute();

// Display the new advertiser.
System.out.printf("Advertiser %s was created.", response.getName());

Python

# Create an advertiser object.
advertiser_obj = {
    'partnerId': partner-id,
    'displayName': display-name,
    'entityStatus': "ENTITY_STATUS_ACTIVE",
    'generalConfig': {
        'domainUrl' : domain-url,
        'currencyCode' : 'USD'
    },
    'adServerConfig': {
        'thirdPartyOnlyConfig' : {}
    },
    'creativeConfig': {},
    'billingConfig': {
        'billingProfileId' : billing-profile-id
    }
}

# Create the advertiser.
advertiser = service.advertisers().create(
    body=advertiser_obj
).execute()

# Display the new advertiser.
print("Advertiser %s was created." % advertiser["name"])

PHP

// Create an advertiser object.
$advertiser = new Google_Service_DisplayVideo_Advertiser();
$advertiser->setPartnerId(partner-id);
$advertiser->setDisplayName(display-name);
$advertiser->setEntityStatus('ENTITY_STATUS_ACTIVE');

// Create and set the advertiser general configuration.
$generalConfig =
    new Google_Service_DisplayVideo_AdvertiserGeneralConfig();
$generalConfig->setDomainUrl(domain-url);
$generalConfig->setCurrencyCode('USD');
$advertiser->setGeneralConfig($generalConfig);

// Create the ad server configuration structure.
$adServerConfig =
    new Google_Service_DisplayVideo_AdvertiserAdServerConfig();

// Create and add the third party only configuration to the ad server
// configuration.
$adServerConfig->setThirdPartyOnlyConfig(
    new Google_Service_DisplayVideo_ThirdPartyOnlyConfig()
);

// Set the ad server configuration.
$advertiser->setAdServerConfig($adServerConfig);

// Create and set the creative configuration.
$advertiser->setCreativeConfig(
    new Google_Service_DisplayVideo_AdvertiserCreativeConfig()
);

// Create and set the billing configuration.
$billingConfig = new Google_Service_DisplayVideo_AdvertiserBillingConfig();
$billingConfig->setBillingProfileId(billing-profile-id);
$advertiser->setBillingConfig($billingConfig);

// Call the API, creating the advertiser.
$result = $this->service->advertisers->create($advertiser);

printf('Advertiser %s was created.\n', $result['name']);

Membuat kampanye

Berikut contoh cara membuat kampanye:

Java

// Create a campaign object.
Campaign campaign = new Campaign();
campaign.setDisplayName(display-name);
campaign.setEntityStatus("ENTITY_STATUS_PAUSED");

// Create a campaign goal object.
CampaignGoal campaignGoal = new CampaignGoal();
campaignGoal.setCampaignGoalType("CAMPAIGN_GOAL_TYPE_BRAND_AWARENESS");

// Create and add a performance goal to the campaign goal object.
PerformanceGoal performanceGoal = new PerformanceGoal();
performanceGoal.setPerformanceGoalType("PERFORMANCE_GOAL_TYPE_CPC");
performanceGoal.setPerformanceGoalAmountMicros(1000000L);
campaignGoal.setPerformanceGoal(performanceGoal);

// Set the campaign goal.
campaign.setCampaignGoal(campaignGoal);

// Create a campaign flight object.
// This object details the planned spend and duration of the campaign.
CampaignFlight campaignFlight = new CampaignFlight();
campaignFlight.setPlannedSpendAmountMicros(1000000L);

// Create the date range for the campaign flight.
DateRange dateRange = new DateRange();

// Set the start date to one week from now and the end date to two weeks
// from now.
Calendar calendarStartDate = Calendar.getInstance().add(Calendar.DATE, 7);
Calendar calendarEndDate = Calendar.getInstance().add(Calendar.DATE, 14);
dateRange.setStartDate(
   new Date()
      .setYear(calendarStartDate.get(Calendar.YEAR))
      .setMonth(calendarStartDate.get(Calendar.MONTH))
      .setDay(calendarStartDate.get(Calendar.DAY_OF_MONTH)));
dateRange.setEndDate(
   new Date()
      .setYear(calendarEndDate.get(Calendar.YEAR))
      .setMonth(calendarEndDate.get(Calendar.MONTH))
      .setDay(calendarEndDate.get(Calendar.DAY_OF_MONTH)));

// Add the planned date range to the campaign flight object.
campaignFlight.setPlannedDates(dateRange);

// Set the campaign flight.
campaign.setCampaignFlight(campaignFlight);

// Create and set the frequency cap.
FrequencyCap frequencyCap = new FrequencyCap();
frequencyCap.setMaxImpressions(10);
frequencyCap.setTimeUnit("TIME_UNIT_DAYS");
frequencyCap.setTimeUnitCount(1);
campaign.setFrequencyCap(frequencyCap);

// Configure the create request.
Campaigns.Create request = service.advertisers().campaigns()
   .create(advertiser-id, campaign);

// Create the campaign.
Campaign response = request.execute();

// Display the new campaign.
System.out.printf("Campaign %s was created.", response.getName());

Python

# Create a future campaign flight start and end dates.
startDate = date.today() + timedelta(days=7)
endDate = date.today() + timedelta(days=14)

# Create a campaign object.
campaign_obj = {
    'displayName': display-name,
    'entityStatus': 'ENTITY_STATUS_PAUSED',
    'campaignGoal': {
        'campaignGoalType' : 'CAMPAIGN_GOAL_TYPE_BRAND_AWARENESS',
        'performanceGoal': {
            'performanceGoalType': 'PERFORMANCE_GOAL_TYPE_CPC',
            'performanceGoalAmountMicros': 1000000
        }
    },
    'campaignFlight': {
        'plannedSpendAmountMicros': 1000000,
        'plannedDates': {
            'startDate': {
                'year': startDate.year,
                'month': startDate.month,
                'day': startDate.day
            },
            'endDate': {
                'year': endDate.year,
                'month': endDate.month,
                'day': endDate.day
            }
        }
    },
    'frequencyCap': {
        'maxImpressions': 10,
        'timeUnit': 'TIME_UNIT_DAYS',
        'timeUnitCount': 1
    }
}

# Create the campaign.
campaign = service.advertisers().campaigns().create(
    advertiserId=advertiser-id,
    body=campaign_obj
).execute()

# Display the new campaign.
print("Campaign %s was created." % campaign["name"])

PHP

// Create a campaign object.
$campaign = new Google_Service_DisplayVideo_Campaign();
$campaign->setDisplayName(display-name);
$campaign->setEntityStatus('ENTITY_STATUS_ACTIVE');

// Create a campaign goal object.
$campaignGoal = new Google_Service_DisplayVideo_CampaignGoal();
$campaignGoal->setCampaignGoalType(
    'CAMPAIGN_GOAL_TYPE_BRAND_AWARENESS'
);

// Create and add a performance goal to the campaign goal object.
$performanceGoal = new Google_Service_DisplayVideo_PerformanceGoal();
$performanceGoal->setPerformanceGoalType('PERFORMANCE_GOAL_TYPE_CPC');
$performanceGoal->setPerformanceGoalAmountMicros(1000000);

// Set the campaign goal.
$campaignGoal->setPerformanceGoal($performanceGoal);
$campaign->setCampaignGoal($campaignGoal);

// Create a campaign flight object.
// This object details the planned spend and duration of the campaign.
$campaignFlight = new Google_Service_DisplayVideo_CampaignFlight();
$campaignFlight->setPlannedSpendAmountMicros(1000000);

// Create a date range object for the flight.
$dateRange = new Google_Service_DisplayVideo_DateRange();

// Create and assign a start date one week from now.
$startDateTime = new DateTime('today + 7 days');
$startDate = new Google_Service_DisplayVideo_Date();
$startDate->setYear($startDateTime->format('Y'));
$startDate->setMonth($startDateTime->format('n'));
$startDate->setDay($startDateTime->format('j'));
$dateRange->setStartDate($startDate);

// Create and assign an end date two weeks from now.
$endDateTime = new DateTime('today + 14 days');
$endDate = new Google_Service_DisplayVideo_Date();
$endDate->setYear($endDateTime->format('Y'));
$endDate->setMonth($endDateTime->format('n'));
$endDate->setDay($endDateTime->format('j'));
$dateRange->setendDate($endDate);

// Assign date range to flight.
$campaignFlight->setPlannedDates($dateRange);

// Assign flight to campaign.
$campaign->setCampaignFlight($campaignFlight);

// Create and set the frequency cap.
$frequencyCap = new Google_Service_DisplayVideo_FrequencyCap();
$frequencyCap->setMaxImpressions(10);
$frequencyCap->setTimeUnit('TIME_UNIT_DAYS');
$frequencyCap->setTimeUnitCount(1);
$campaign->setFrequencyCap($frequencyCap);

// Call the API, creating the campaign under the given advertiser.
$result = $this->service->advertisers_campaigns->create(
    advertiser-id,
    $campaign
);

// Display the new campaign.
printf('Campaign %s was created.\n', $result['name']);

Membuat pesanan pemasangan iklan

Berikut adalah contoh cara membuat perjanjian pemasangan iklan:

Java

// Create an insertion order object.
InsertionOrder insertionOrder = new InsertionOrder();
insertionOrder.setCampaignId(campaign-id);
insertionOrder.setDisplayName(display-name);
insertionOrder.setEntityStatus("ENTITY_STATUS_DRAFT");

// Create and add the pacing setting.
Pacing pacing = new Pacing();
pacing.setPacingPeriod("PACING_PERIOD_DAILY");
pacing.setPacingType("PACING_TYPE_EVEN");
pacing.setDailyMaxMicros(10000L);
insertionOrder.setPacing(pacing);

// Create and set the frequency cap.
FrequencyCap frequencyCap = new FrequencyCap();
frequencyCap.setTimeUnit("TIME_UNIT_DAYS");
frequencyCap.setTimeUnitCount(1);
frequencyCap.setMaxImpressions(10);
insertionOrder.setFrequencyCap(frequencyCap);

// Create and set the key performance indicator (KPI).
Kpi kpi = new Kpi();
kpi.setKpiType("KPI_TYPE_CPC");
kpi.setKpiAmountMicros(1000000L);
insertionOrder.setKpi(kpi);

// Create a budget object.
InsertionOrderBudget insertionOrderBudget = new InsertionOrderBudget();
insertionOrderBudget.setBudgetUnit("BUDGET_UNIT_CURRENCY");

// Create a budget segment object.
InsertionOrderBudgetSegment insertionOrderBudgetSegment =
   new InsertionOrderBudgetSegment();
insertionOrderBudgetSegment.setBudgetAmountMicros(100000L);

// Create the date range for the budget segment.
DateRange dateRange = new DateRange();

// Set the start date to one week from now and the end date to two weeks
// from now.
Calendar calendarStartDate = Calendar.getInstance().add(Calendar.DATE, 7);
Calendar calendarEndDate = Calendar.getInstance().add(Calendar.DATE, 14);
dateRange.setStartDate(
   new Date()
      .setYear(calendarStartDate.get(Calendar.YEAR))
      .setMonth(calendarStartDate.get(Calendar.MONTH))
      .setDay(calendarStartDate.get(Calendar.DAY_OF_MONTH)));
dateRange.setEndDate(
   new Date()
      .setYear(calendarEndDate.get(Calendar.YEAR))
      .setMonth(calendarEndDate.get(Calendar.MONTH))
      .setDay(calendarEndDate.get(Calendar.DAY_OF_MONTH)));

// Add the date range to the budget segment.
insertionOrderBudgetSegment.setDateRange(dateRange);

// Add budget segment list to the budget.
insertionOrderBudget
   .setBudgetSegments(ImmutableList.of(insertionOrderBudgetSegment));

// Set budget.
insertionOrder.setBudget(insertionOrderBudget);

// Configure the create request.
InsertionOrders.Create request =
   service.advertisers().insertionOrders()
       .create(advertiser-id, insertionOrder);

// Create the insertion order.
InsertionOrder response = request.execute();

// Display the new insertion order.
System.out.printf("InsertionOrder %s was created.", response.getName());

Python

# Create a future budget segment start and end dates.
startDate = date.today() + timedelta(days=7)
endDate = date.today() + timedelta(days=14)

# Create an insertion order object.
insertion_order_obj = {
    'campaignId' : campaign-id,
    'displayName': display-name,
    'entityStatus': 'ENTITY_STATUS_DRAFT',
    'pacing': {
        'pacingPeriod': 'PACING_PERIOD_DAILY',
        'pacingType': 'PACING_TYPE_EVEN',
        'dailyMaxMicros': 10000
    },
    'frequencyCap': {
        'maxImpressions': 10,
        'timeUnit': 'TIME_UNIT_DAYS',
        'timeUnitCount': 1
    },
    'kpi' : {
        'kpiType': 'KPI_TYPE_CPC',
        'kpiAmountMicros': 1000000
    },
    'budget': {
        'budgetUnit': 'BUDGET_UNIT_CURRENCY',
        'budgetSegments': [
            {
                'budgetAmountMicros': 100000,
                'dateRange': {
                    'startDate': {
                        'year': startDate.year,
                        'month': startDate.month,
                        'day': startDate.day
                    },
                    'endDate': {
                        'year': endDate.year,
                        'month': endDate.month,
                        'day': endDate.day
                    }
                }
            }
        ]
    }
}

# Create the insertion order.
insertionOrder = service.advertisers().insertionOrders().create(
    advertiserId=advertiser-id,
    body=insertion_order_obj
).execute()

# Display the new insertion order.
print("Insertion Order %s was created." % insertionOrder["name"])

PHP

// Create an insertion order object.
$insertionOrder = new Google_Service_DisplayVideo_InsertionOrder();
$insertionOrder->setCampaignId(campaign-id);
$insertionOrder->setDisplayName(display-name);
$insertionOrder->setEntityStatus('ENTITY_STATUS_DRAFT');

// Create and add the pacing setting.
$pacing = new Google_Service_DisplayVideo_Pacing();
$pacing->setPacingPeriod('PACING_PERIOD_DAILY');
$pacing->setPacingType('PACING_TYPE_EVEN');
$pacing->setDailyMaxMicros(10000);
$insertionOrder->setPacing($pacing);

// Create and set the frequency cap.
$frequencyCap = new Google_Service_DisplayVideo_FrequencyCap();
$frequencyCap->setMaxImpressions(10);
$frequencyCap->setTimeUnit('TIME_UNIT_DAYS');
$frequencyCap->setTimeUnitCount(1);
$insertionOrder->setFrequencyCap($frequencyCap);

// Create and set the key performance indicator (KPI).
$kpi = new Google_Service_DisplayVideo_Kpi();
$kpi->setKpiType('KPI_TYPE_CPC');
$kpi->setKpiAmountMicros(1000000);
$insertionOrder->setKpi($kpi);

// Create a budget object.
$budget = new Google_Service_DisplayVideo_InsertionOrderBudget();
$budget->setBudgetUnit('BUDGET_UNIT_CURRENCY');

// Create a budget segment object.
$budgetSegment =
    new Google_Service_DisplayVideo_InsertionOrderBudgetSegment();
$budgetSegment->setBudgetAmountMicros(100000);

// Create a date range object for the budget segment.
$dateRange = new Google_Service_DisplayVideo_DateRange();

// Create and assign a start date one week from now.
$startDateTime = new DateTime('today + 7 days');
$startDate = new Google_Service_DisplayVideo_Date();
$startDate->setYear($startDateTime->format('Y'));
$startDate->setMonth($startDateTime->format('n'));
$startDate->setDay($startDateTime->format('j'));
$dateRange->setStartDate($startDate);

// Create and assign an end date two weeks from now.
$endDateTime = new DateTime('today + 14 days');
$endDate = new Google_Service_DisplayVideo_Date();
$endDate->setYear($endDateTime->format('Y'));
$endDate->setMonth($endDateTime->format('n'));
$endDate->setDay($endDateTime->format('j'));
$dateRange->setendDate($endDate);

// Assign date range to budget segment.
$budgetSegment->setDateRange($dateRange);

// Set budget segment.
$budget->setBudgetSegments(array($budgetSegment));

// Set budget object.
$insertionOrder->setBudget($budget);

// Call the API, creating the insertion order under the advertiser and
// campaign given.
$result = $this->service->advertisers_insertionOrders->create(
    advertiser-id,
    $insertionOrder
);

printf('Insertion Order %s was created.\n', $result['name']);

Membuat item baris

Berikut adalah contoh cara membuat item baris:

Java

// Create a line item object.
LineItem lineItem = new LineItem();
lineItem.setInsertionOrderId(insertion-order-id);
lineItem.setDisplayName(display-name);
lineItem.setLineItemType("LINE_ITEM_TYPE_DISPLAY_DEFAULT");
lineItem.setEntityStatus("ENTITY_STATUS_DRAFT");

// Create and set the line item flight.
LineItemFlight lineItemFlight = new LineItemFlight();
lineItemFlight
   .setFlightDateType("LINE_ITEM_FLIGHT_DATE_TYPE_INHERITED");
lineItem.setFlight(lineItemFlight);

// Create and set the line item budget.
LineItemBudget lineItemBudget = new LineItemBudget();
lineItemBudget
   .setBudgetAllocationType("LINE_ITEM_BUDGET_ALLOCATION_TYPE_FIXED");
lineItem.setBudget(lineItemBudget);

// Create and set the pacing setting.
Pacing pacing = new Pacing();
pacing.setPacingPeriod("PACING_PERIOD_DAILY");
pacing.setPacingType("PACING_TYPE_EVEN");
pacing.setDailyMaxMicros(10000L);
lineItem.setPacing(pacing);

// Create and set the frequency cap.
FrequencyCap frequencyCap = new FrequencyCap();
frequencyCap.setTimeUnit("TIME_UNIT_DAYS");
frequencyCap.setTimeUnitCount(1);
frequencyCap.setMaxImpressions(10);
lineItem.setFrequencyCap(frequencyCap);

// Create and set the partner revenue model.
PartnerRevenueModel partnerRevenueModel = new PartnerRevenueModel();
partnerRevenueModel
   .setMarkupType("PARTNER_REVENUE_MODEL_MARKUP_TYPE_CPM");
partnerRevenueModel.setMarkupAmount(10L);
lineItem.setPartnerRevenueModel(partnerRevenueModel);

// Set the list of IDs of the creatives associated with the line item.
lineItem.setCreativeIds(creative-ids);

// Create and set the bidding strategy.
BiddingStrategy biddingStrategy = new BiddingStrategy();
biddingStrategy
   .setFixedBid(new FixedBidStrategy().setBidAmountMicros(100000L));
lineItem.setBidStrategy(biddingStrategy);

// Configure the create request.
LineItems.Create request =
   service.advertisers().lineItems().create(advertiser-id, lineItem);

// Create the line item.
LineItem response = request.execute();

// Display the new line item.
System.out.printf("LineItem %s was created.", response.getName());

Python

# Create an line item object.
line_item_obj = {
    'insertionOrderId' : insertion-order-id,
    'displayName': display-name,
    'lineItemType': 'LINE_ITEM_TYPE_DISPLAY_DEFAULT',
    'entityStatus': 'ENTITY_STATUS_DRAFT',
    'flight': {
        'flightDateType': 'LINE_ITEM_FLIGHT_DATE_TYPE_INHERITED'
    },
    'budget': {
        'budgetAllocationType': 'LINE_ITEM_BUDGET_ALLOCATION_TYPE_FIXED'
    },
    'pacing': {
        'pacingPeriod': 'PACING_PERIOD_DAILY',
        'pacingType': 'PACING_TYPE_EVEN',
        'dailyMaxMicros': 10000
    },
    'frequencyCap': {
        'timeUnit': 'TIME_UNIT_DAYS',
        'timeUnitCount': 1,
        'maxImpressions': 10
    },
    'partnerRevenueModel': {
        'markupType': 'PARTNER_REVENUE_MODEL_MARKUP_TYPE_CPM',
        'markupAmount': 10
    },
    'creativeIds': creative-ids,
    'bidStrategy': {
        'fixedBid': {
            'bidAmountMicros': 100000
        }
    }
}

# Create the line item.
lineItem = service.advertisers().lineItems().create(
    advertiserId=advertiser-id,
    body=line_item_obj
).execute()

# Display the new line item.
print("Line Item %s was created." % lineItem["name"])

PHP

// Create a line item object.
$lineItem = new Google_Service_DisplayVideo_LineItem();
$lineItem->setInsertionOrderId(insertion-order-id);
$lineItem->setDisplayName(display-name);
$lineItem->setLineItemType('LINE_ITEM_TYPE_DISPLAY_DEFAULT');
$lineItem->setEntityStatus('ENTITY_STATUS_DRAFT');

// Create and set the line item flight.
$flight = new Google_Service_DisplayVideo_LineItemFlight();
$flight->setFlightDateType('LINE_ITEM_FLIGHT_DATE_TYPE_INHERITED');
$lineItem->setFlight($flight);

// Create and set the line item budget.
$budget = new Google_Service_DisplayVideo_LineItemBudget();
$budget->setBudgetAllocationType(
    'LINE_ITEM_BUDGET_ALLOCATION_TYPE_FIXED'
);
$lineItem->setBudget($budget);

// Create and set the pacing setting.
$pacing = new Google_Service_DisplayVideo_Pacing();
$pacing->setPacingPeriod('PACING_PERIOD_DAILY');
$pacing->setPacingType('PACING_TYPE_EVEN');
$pacing->setDailyMaxMicros(10000);
$lineItem->setPacing($pacing);

// Create and set the frequency cap.
$frequencyCap = new Google_Service_DisplayVideo_FrequencyCap();
$frequencyCap->setMaxImpressions(10);
$frequencyCap->setTimeUnit('TIME_UNIT_DAYS');
$frequencyCap->setTimeUnitCount(1);
$lineItem->setFrequencyCap($frequencyCap);

// Create and set the partner revenue model.
$partnerRevenueModel =
    new Google_Service_DisplayVideo_PartnerRevenueModel();
$partnerRevenueModel->setMarkupType(
    'PARTNER_REVENUE_MODEL_MARKUP_TYPE_CPM'
);
$partnerRevenueModel->setMarkupAmount(10);
$lineItem->setPartnerRevenueModel($partnerRevenueModel);

// Set the list of IDs of the creatives associated with the line item.
lineItem >setCreativeIds(creative-ids);

// Create and set the bidding strategy.
$biddingStrategy =  new Google_Service_DisplayVideo_BiddingStrategy();
$fixedBidStrategy = new Google_Service_DisplayVideo_FixedBidStrategy();
$fixedBidStrategy->setBidAmountMicros(100000);
$biddingStrategy->setFixedBid($fixedBidStrategy);
$lineItem->setBidStrategy($biddingStrategy);

// Create the line item.
$result = $this->service->advertisers_lineItems->create(
    advertiser-id,
    $lineItem
);

printf('Line Item %s was created.\n', $result['name']);

Buat Item Baris Default

Item baris dapat dibuat dengan konfigurasi default yang ditentukan oleh LineItemType tertentu serta konfigurasi yang ada dari perjanjian pemasangan iklan induknya. Tidak seperti pembuatan item baris API standar, item baris default diberi penargetan yang sama dengan pesanan pemasangan iklan induknya setelah pembuatan, mirip dengan yang terjadi di UI. Kelola ini menggunakan layanan pesanan pemasangan iklan AssignedTargetingOptions

Berikut adalah contoh cara membuat item baris default:

Java

// Create a default line item generation request.
GenerateDefaultLineItemRequest defaultLineItemRequest =
    new GenerateDefaultLineItemRequest();
defaultLineItemRequest.setInsertionOrderId(insertion-order-id);
defaultLineItemRequest.setDisplayName(display-name);
defaultLineItemRequest.setLineItemType("LINE_ITEM_TYPE_DISPLAY_DEFAULT");

// Configure the request.
LineItems.GenerateDefault request =
    service
        .advertisers()
        .lineItems()
        .generateDefault(advertiser-id, defaultLineItemRequest);

// Generate the default line item.
LineItem response = request.execute();

// Display the new line item.
System.out.printf("LineItem %s was created.", response.getName());

Python

# Create a default line item generation request.
default_li_request = {
    'insertionOrderId' : insertion-order-id,
    'displayName': display-name,
    'lineItemType': 'LINE_ITEM_TYPE_DISPLAY_DEFAULT'
}

# Generate the default line item.
line_item = service.advertisers().lineItems().generateDefault(
    advertiserId=advertiser-id,
    body=default_li_request
).execute()

# Display the new line item.
print("Line Item %s was created." % lineItem["name"])

PHP

// Create a default line item generation request.
$defaultLineItemRequest =
    new Google_Service_DisplayVideo_GenerateDefaultLineItemRequest();
$defaultLineItemRequest->setInsertionOrderId(insertion-order-id);
$defaultLineItemRequest->setDisplayName(display-name);
$defaultLineItemRequest->setLineItemType('LINE_ITEM_TYPE_DISPLAY_DEFAULT');

// Generate the default line item.
$result = $this->service->advertisers_lineItems->generateDefault(
    advertiser-id,
    $defaultLineItemRequest
);

// Display the new line item.
printf('Line Item %s was created.\n', $result['name']);

Item Baris Duplikat

Item baris yang sudah ada dapat diduplikasi, sehingga menghasilkan item baris baru dengan konfigurasi dan setelan penargetan yang sama seperti item baris yang sudah ada yang dibuat dengan perjanjian pemasangan iklan yang sama.

Berikut adalah contoh cara menduplikasi item baris yang ada:

Java

// Create the duplicate line item request body.
DuplicateLineItemRequest requestBody = new DuplicateLineItemRequest();
requestBody.setTargetDisplayName(target-display-name);

// Configure the request.
LineItems.Duplicate request = service.advertisers().lineItems()
    .duplicate(advertiser-id, line-item-id, requestBody);

// Duplicate the line item.
DuplicateLineItemResponse response = request.execute();

// Display the line item ID of the new duplicate line item.
System.out.printf("A duplicate line item with the ID %s was created.",
    response.getDuplicateLineItemId());

Python

# Create the duplicate line item request body.
duplicate_request = {
    'targetDisplayName': target-display-name
}

# Duplicate the line item.
response = service.advertisers().lineItems().duplicate(
    advertiserId=advertiser-id,
    lineItemId=line-item-id,
    body=duplicate_request
).execute()

# Display the line item ID of the new duplicate line item.
print("A duplicate line item with the ID %s was created."
      % response["duplicateLineItemId"])

PHP

// Create the duplicate line item request body.
$requestBody = new Google_Service_DisplayVideo_DuplicateLineItemRequest();
$requestBody->setTargetDisplayName(target-display-name);

// Call the API, duplicating the line item.
$response = $service
    ->advertisers_lineItems
    ->duplicate(
        advertiser-id,
        line-item-id,
        $requestBody
    );

// Display the line item ID of the new duplicate line item.
printf(
    'A duplicate line item with the ID %s was created.',
    $response->getDuplicateLineItemId()
);