Create and run reports

  • Interactive reports can be created and run using the Ad Manager API, including running existing reports created in the Ad Manager UI.

  • After initiating a report run, its status can be polled, and the results can be read upon completion.

  • Creating a report involves using the networks.reports.create method to define the report parameters like dimensions, metrics, and date range.

  • Running a report requires its ID, which can be obtained from the Ad Manager UI or by listing reports using the API.

  • Once a report run operation is complete, the result resource name can be obtained to fetch paginated rows of report data using networks.reports.results.fetchRows .

Using the Ad Manager API, you can create and run Interactive reports. For details on Interactive reporting in Ad Manager, see Create an Interactive report . With Interactive reports, you can do the following:

  • Create a new report using the API, and initiate a run.
  • Run an existing report you created in the Ad Manager UI.

After you initiate a report run, you can poll the report's status and read the results after completion.

This guide covers how to create a report, initiate an asynchronous run of a Report , poll the returned Operation status, obtain the Result resource name from the completed Operation and fetch a paginated set of result Rows .

Prerequisite

Before continuing, verify that you have access to a Google Ad Manager network. To get access, see Get started with Google Ad Manager and user role permissions for Reports .

Create a report

Using the networks.reports.create method, you can create a Report object.

The following example creates a report that shows yesterday's impressions broken down by line item:

Java

  import 
  
 com.google.ads.admanager.v1.CreateReportRequest 
 ; 
 import 
  
 com.google.ads.admanager.v1.NetworkName 
 ; 
 import 
  
 com.google.ads.admanager.v1.Report 
 ; 
 import 
  
 com.google.ads.admanager.v1.ReportServiceClient 
 ; 
 public 
  
 class 
 SyncCreateReport 
  
 { 
  
 public 
  
 static 
  
 void 
  
 main 
 ( 
 String 
 [] 
  
 args 
 ) 
  
 throws 
  
 Exception 
  
 { 
  
 syncCreateReport 
 (); 
  
 } 
  
 public 
  
 static 
  
 void 
  
 syncCreateReport 
 () 
  
 throws 
  
 Exception 
  
 { 
  
 try 
  
 ( 
 ReportServiceClient 
  
 reportServiceClient 
  
 = 
  
 ReportServiceClient 
 . 
 create 
 ()) 
  
 { 
  
 Report 
  
 report 
  
 = 
  
 Report 
 . 
 newBuilder 
 () 
  
 . 
 setDisplayName 
 ( 
 "My API Report" 
 ) 
  
 . 
 setReportDefinition 
 ( 
  
 ReportDefinition 
 . 
 newBuilder 
 () 
  
 . 
 addDimensions 
 ( 
 Dimension 
 . 
 LINE_ITEM_NAME 
 ) 
  
 . 
 addDimensions 
 ( 
 Dimension 
 . 
 LINE_ITEM_ID 
 ) 
  
 . 
 addMetrics 
 ( 
 Metric 
 . 
 AD_SERVER_IMPRESSIONS 
 ) 
  
 . 
 setDateRange 
 ( 
 DateRange 
 . 
 newBuilder 
 (). 
 setRelative 
 ( 
 RelativeDateRange 
 . 
 YESTERDAY 
 )) 
  
 . 
 setReportType 
 ( 
 ReportType 
 . 
 HISTORICAL 
 ) 
  
 . 
 build 
 ()) 
  
 . 
 build 
 (); 
  
 CreateReportRequest 
  
 request 
  
 = 
  
 CreateReportRequest 
 . 
 newBuilder 
 () 
  
 . 
 setParent 
 ( 
 NetworkName 
 . 
 of 
 ( 
 " NETWORK_CODE 
" 
 ). 
 toString 
 ()) 
  
 . 
 setReport 
 ( 
 report 
 ) 
  
 . 
 build 
 (); 
  
 Report 
  
 response 
  
 = 
  
 reportServiceClient 
 . 
 createReport 
 ( 
 request 
 ); 
  
 } 
  
 } 
 } 
  
 

Python

 from 
  
 google.ads 
  
 import 
 admanager_v1 
 from 
  
 google.ads.admanager_v1 
  
 import 
 Report 
 def 
  
 sample_create_report 
 (): 
 # Create a client 
 client 
 = 
 admanager_v1 
 . 
 ReportServiceClient 
 () 
 # Initialize request argument(s) 
 report 
 = 
 admanager_v1 
 . 
 Report 
 ( 
 display_name 
 = 
 "My API Report" 
 , 
 report_definition 
 = 
 admanager_v1 
 . 
 ReportDefinition 
 ( 
 dimensions 
 = 
 [ 
 Report 
 . 
 Dimension 
 . 
 LINE_ITEM_NAME 
 , 
 Report 
 . 
 Dimension 
 . 
 LINE_ITEM_ID 
 , 
 ], 
 metrics 
 = 
 [ 
 Report 
 . 
 Metric 
 . 
 AD_SERVER_IMPRESSIONS 
 , 
 ], 
 date_range 
 = 
 Report 
 . 
 DateRange 
 ( 
 relative 
 = 
 Report 
 . 
 DateRange 
 . 
 RelativeDateRange 
 . 
 YESTERDAY 
 ), 
 report_type 
 = 
 Report 
 . 
 ReportType 
 . 
 HISTORICAL 
 , 
 ) 
 ) 
 request 
 = 
 admanager_v1 
 . 
 CreateReportRequest 
 ( 
 parent 
 = 
 "networks/ NETWORK_CODE 
" 
 , 
 report 
 = 
 report 
 , 
 ) 
 # Make the request 
 response 
 = 
 client 
 . 
 create_report 
 ( 
 request 
 = 
 request 
 ) 
 # Handle the response 
 print 
 ( 
 response 
 ) 
  

.NET

  using 
  
 Google.Ads.AdManager.V1 
 ; 
 using 
  
 Dimension 
  
 = 
  
 Google 
 . 
 Ads 
 . 
 AdManager 
 . 
 V1 
 . 
 Report 
 . 
 Types 
 . 
 Dimesnsion 
 ; 
 using 
  
 Metric 
  
 = 
  
 Google 
 . 
 Ads 
 . 
 AdManager 
 . 
 V1 
 . 
 Report 
 . 
 Types 
 . 
 Metric 
 ; 
 public 
  
 sealed 
  
 partial 
  
 class 
  
 GeneratedReportServiceClientSnippets 
 { 
  
 public 
  
 void 
  
 CreateReport 
 () 
  
 { 
  
 // Create client 
  
 ReportServiceClient 
  
 reportServiceClient 
  
 = 
  
 ReportServiceClient 
 . 
 Create 
 (); 
  
 // Initialize request argument(s) 
  
 string 
  
 parent 
  
 = 
  
 "networks/ NETWORK_CODE 
" 
 ; 
  
 Report 
  
 report 
  
 = 
  
 new 
  
 Report 
  
 { 
  
 DisplayName 
  
 = 
  
 "My API Report" 
 , 
  
 ReportDefinition 
  
 = 
  
 new 
  
 ReportDefinition 
  
 { 
  
 Dimensions 
  
 = 
  
 { 
  
 Dimension 
 . 
 LineItemName 
 , 
  
 Dimension 
 . 
 LineItemId 
  
 }, 
  
 Metrics 
  
 = 
  
 { 
  
 Metric 
 . 
 AdServerImpressions 
  
 }, 
  
 DateRange 
  
 = 
  
 new 
  
 Report 
 . 
 Types 
 . 
 DateRange 
  
 { 
  
 Relative 
  
 = 
  
 Report 
 . 
 Types 
 . 
 DateRange 
 . 
 Types 
 . 
 RelativeDateRange 
 . 
 Yesterday 
  
 }, 
  
 ReportType 
  
 = 
  
 Report 
 . 
 Types 
 . 
 ReportType 
 . 
 Historical 
  
 } 
  
 }; 
  
 // Make the request 
  
 Report 
  
 response 
  
 = 
  
 reportServiceClient 
 . 
 CreateReport 
 ( 
 parent 
 , 
  
 report 
 ); 
  
 } 
 } 
  
 

PHP

  
Create a Mobile Website
View Site in Mobile | Classic
Share by: