Create a line item

A line item bids on impressions and serves creative purchased ads inventory. LineItem resources do this based on set budget, bid strategy, and targeting.

YouTube and Demand Gen line items have child resources called ad groups. Ad groups provide another level of targeting under a single line item budget.

Choose configurations

Before creating a line item, review and decide on these settings:

The LineItem resource also has many optional fields. Some are only used by certain types of line items. Read the reference documentation for more information.

Choose creatives

You need to assign at least one valid, approved creative to line item before it begins serving. The line item type will restrict the kind of creatives you can assign.

Use the creative list function to retrieve existing creatives. If you need to create a new creative for the line item, follow our Assign a creative guide. Assign the creative to the line item using its ID.

How to create a line item

Here's how to create a display line item with the following settings:

  • A inherited flight and budget.
  • A partner revenue model of 0.1% of total media cost.
  • A bid strategy set to maximize spend based on viewable impressions.

Java

 // Provide the ID of the parent advertiser. 
 long 
  
 advertiserId 
  
 = 
  
  advertiser 
 - 
 id 
 
 // Provide the ID of the parent insertion order. 
 long 
  
 insertionOrderId 
  
 = 
  
  insertion 
 - 
 order 
 - 
 id 
 
 // Provide the display name of the line item. 
 String 
  
 displayName 
  
 = 
  
  display 
 - 
 name 
 
 // Provide the list of IDs of the creative resources that the line item will 
 // serve. 
 List<Long 
 > 
  
 creativeIds 
  
 = 
  
  creative 
 - 
 ids 
 
 ; 
 // Provide whether the line item will serve EU political ads. 
 String 
  
 containsEuPoliticalAds 
  
 = 
  
  contains 
 - 
 eu 
 - 
 political 
 - 
 ads 
 
 // Create the line item structure. 
 LineItem 
  
 lineItem 
  
 = 
  
 new 
  
 LineItem 
 () 
  
 . 
 setInsertionOrderId 
 ( 
 insertionOrderId 
 ) 
  
 . 
 setDisplayName 
 ( 
 displayName 
 ) 
  
 . 
 setLineItemType 
 ( 
 "LINE_ITEM_TYPE_DISPLAY_DEFAULT" 
 ) 
  
 . 
 setEntityStatus 
 ( 
 "ENTITY_STATUS_DRAFT" 
 ) 
  
 . 
 setCreativeIds 
 ( 
 creativeIds 
 ) 
  
 . 
 setContainsEuPoliticalAds 
 ( 
 containsEuPoliticalAds 
 ); 
 // Create and set the line item flight. 
 LineItemFlight 
  
 lineItemFlight 
  
 = 
  
 new 
  
 LineItemFlight 
 (). 
 setFlightDateType 
 ( 
 "LINE_ITEM_FLIGHT_DATE_TYPE_INHERITED" 
 ); 
 lineItem 
 . 
 setFlight 
 ( 
 lineItemFlight 
 ); 
 // Create and set the line item budget. 
 LineItemBudget 
  
 lineItemBudget 
  
 = 
  
 new 
  
 LineItemBudget 
 (). 
 setBudgetAllocationType 
 ( 
 "LINE_ITEM_BUDGET_ALLOCATION_TYPE_UNLIMITED" 
 ); 
 lineItem 
 . 
 setBudget 
 ( 
 lineItemBudget 
 ); 
 // Create and set the pacing setting. 
 Pacing 
  
 pacing 
  
 = 
  
 new 
  
 Pacing 
 () 
  
 . 
 setPacingPeriod 
 ( 
 "PACING_PERIOD_FLIGHT" 
 ) 
  
 . 
 setPacingType 
 ( 
 "PACING_TYPE_ASAP" 
 ) 
  
 . 
 setDailyMaxMicros 
 ( 
 10_000L 
 ); 
 lineItem 
 . 
 setPacing 
 ( 
 pacing 
 ); 
 // Create and set the frequency cap. 
 FrequencyCap 
  
 frequencyCap 
  
 = 
  
 new 
  
 FrequencyCap 
 (). 
 setTimeUnit 
 ( 
 "TIME_UNIT_DAYS" 
 ). 
 setTimeUnitCount 
 ( 
 1 
 ). 
 setMaxImpressions 
 ( 
 10 
 ); 
 lineItem 
 . 
 setFrequencyCap 
 ( 
 frequencyCap 
 ); 
 // Create and set the partner revenue model. 
 PartnerRevenueModel 
  
 partnerRevenueModel 
  
 = 
  
 new 
  
 PartnerRevenueModel 
 () 
  
 . 
 setMarkupType 
 ( 
 "PARTNER_REVENUE_MODEL_MARKUP_TYPE_TOTAL_MEDIA_COST_MARKUP" 
 ) 
  
 . 
 setMarkupAmount 
 ( 
 100L 
 ); 
 lineItem 
 . 
 setPartnerRevenueModel 
 ( 
 partnerRevenueModel 
 ); 
 // Create and set the bidding strategy. 
 BiddingStrategy 
  
 biddingStrategy 
  
 = 
  
 new 
  
 BiddingStrategy 
 () 
  
 . 
 setMaximizeSpendAutoBid 
 ( 
  
 new 
  
 MaximizeSpendBidStrategy 
 () 
  
 . 
 setPerformanceGoalType 
 ( 
 "BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_AV_VIEWED" 
 )); 
 lineItem 
 . 
 setBidStrategy 
 ( 
 biddingStrategy 
 ); 
 // Configure the create request. 
 LineItems 
 . 
 Create 
  
 request 
  
 = 
  
 service 
 . 
 advertisers 
 (). 
 lineItems 
 (). 
 create 
 ( 
 advertiserId 
 , 
  
 lineItem 
 ); 
 // Create the line item. 
 LineItem 
  
 response 
  
 = 
  
 request 
 . 
 execute 
 (); 
 // Display the new line item ID. 
 System 
 . 
 out 
 . 
 printf 
 ( 
 "Line Item %s was created." 
 , 
  
 response 
 . 
 getName 
 ()); 

Python

 # Provide the ID of the parent advertiser. 
 advertiser_id 
 = 
  advertiser 
 - 
 id 
 
 # Provide the ID of the parent insertion order. 
 insertion_order_id 
 = 
  insertion 
 - 
 order 
 - 
 id 
 
 # Provide the display name of the line item. 
 display_name 
 = 
  display 
 - 
 name 
 
 # Provide the list of IDs of the creative resources that the line item will 
 # serve. 
 creative_ids 
 = 
  creative 
 - 
 ids 
 
 # Provide whether the line item will serve EU political ads. 
 contains_eu_political_ads 
 = 
  contains 
 - 
 eu 
 - 
 political 
 - 
 ads 
 
 # Create a line item object with example values. 
 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_UNLIMITED" 
 }, 
 "pacing" 
 : 
 { 
 "pacingPeriod" 
 : 
 "PACING_PERIOD_FLIGHT" 
 , 
 "pacingType" 
 : 
 "PACING_TYPE_ASAP" 
 , 
 "dailyMaxMicros" 
 : 
 10000 
 , 
 }, 
 "frequencyCap" 
 : 
 { 
 "timeUnit" 
 : 
 "TIME_UNIT_DAYS" 
 , 
 "timeUnitCount" 
 : 
 1 
 , 
 "maxImpressions" 
 : 
 10 
 , 
 }, 
 "partnerRevenueModel" 
 : 
 { 
 "markupType" 
 : 
 ( 
 "PARTNER_REVENUE_MODEL_MARKUP_TYPE_TOTAL_MEDIA_COST_MARKUP" 
 ), 
 "markupAmount" 
 : 
 100 
 , 
 }, 
 "creativeIds" 
 : 
 creative_ids 
 , 
 "bidStrategy" 
 : 
 { 
 "maximizeSpendAutoBid" 
 : 
 { 
 "performanceGoalType" 
 : 
 ( 
 "BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_AV_VIEWED" 
 ) 
 } 
 }, 
 "contains_eu_political_ads" 
 : 
 contains_eu_political_ads 
 , 
 } 
 # Build and execute request. 
 response 
 = 
 ( 
 service 
 . 
 advertisers 
 () 
 . 
 lineItems 
 () 
 . 
 create 
 ( 
 advertiserId 
 = 
 advertiser_id 
 , 
 body 
 = 
 line_item_obj 
 ) 
 . 
 execute 
 () 
 ) 
 # Display the new line item. 
 print 
 ( 
 f 
 "Line Item 
 { 
 response 
 [ 
 'name' 
 ] 
 } 
 was created." 
 ) 

PHP

 // Provide the ID of the parent advertiser. 
 $advertiserId = advertiser-id 
; 
 // Provide the ID of the parent insertion order. 
 $insertionOrderId = insertion-order-id 
; 
 // Provide the display name of the line item. 
 $displayName = display-name 
; 
 // Provide the list of IDs of the creative resources that the line item 
 // will serve. 
 $creativeIds = creative-ids 
; 
 // Provide whether the line item will serve EU political ads. 
 $containsEuPoliticalAds = contains-eu-political-ads 
; 
 // Create the line item structure. 
 $lineItem = new Google_Service_DisplayVideo_LineItem(); 
 $lineItem->setInsertionOrderId($insertionOrderId); 
 $lineItem->setDisplayName($displayName); 
 $lineItem->setLineItemType('LINE_ITEM_TYPE_DISPLAY_DEFAULT'); 
 $lineItem->setEntityStatus('ENTITY_STATUS_DRAFT'); 
 $lineItem->setCreativeIds($creativeIds); 
 $lineItem->setContainsEuPoliticalAds($containsEuPoliticalAds); 
 // 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_UNLIMITED' 
 ); 
 $lineItem->setBudget($budget); 
 // Create and set the pacing setting. 
 $pacing = new Google_Service_DisplayVideo_Pacing(); 
 $pacing->setPacingPeriod('PACING_PERIOD_FLIGHT'); 
 $pacing->setPacingType('PACING_TYPE_ASAP'); 
 $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_TOTAL_MEDIA_COST_MARKUP' 
 ); 
 $partnerRevenueModel->setMarkupAmount(100); 
 $lineItem->setPartnerRevenueModel($partnerRevenueModel); 
 // Create and set the bidding strategy. 
 $maxSpendBidStrategy = new Google_Service_DisplayVideo_MaximizeSpendBidStrategy(); 
 $maxSpendBidStrategy->setPerformanceGoalType('BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_AV_VIEWED'); 
 $biddingStrategy = new Google_Service_DisplayVideo_BiddingStrategy(); 
 $biddingStrategy->setMaximizeSpendAutoBid($maxSpendBidStrategy); 
 $lineItem->setBidStrategy($biddingStrategy); 
 // Call the API, creating the line item under the advertiser and 
 // insertion order given. 
 try { 
 $result = $this->service->advertisers_lineItems->create( 
 $advertiserId, 
 $lineItem 
 ); 
 } catch (\Exception $e) { 
 $this->renderError($e); 
 return; 
 } 
 // Display the new line item ID. 
 printf('<p>Line Item %s was created.</p>', $result['name']); 
Create a Mobile Website
View Site in Mobile | Classic
Share by: