شما میتوانید با استفاده از رابط کاربری یا API گوگل دیسپلی و ویدیو ۳۶۰، گزارشها را ایجاد و برنامهریزی کنید. به عنوان مثال، کاربران نهایی میتوانند یک گزارش روزانه که تعداد بازدیدهای دیروز را نشان میدهد یا یک گزارش ماهانه که کل هزینهها را نشان میدهد، تنظیم کنند.
ایجاد گزارشهای زمانبندیشده
یک گزارش زمانبندیشده جدید را در رابط گزارشدهی Display & Video 360 یا با استفاده از متد queries.create API ایجاد کنید. جزئیات کامل در مورد عملکرد گزارشدهی Display & Video 360 و نحوه ایجاد گزارشهای جدید را میتوانید در سایت پشتیبانی Display & Video 360 بیابید.
گزارشها را میتوان در زمان ایجاد با استفاده از فیلد Repeats در رابط کاربری و فیلد schedule در API زمانبندی کرد. این فیلدها باید روی یک بازه زمانی مناسب تنظیم شوند.
پس از تنظیم فیلد مناسب، این گزارش طبق برنامهی زمانی تعیینشده اجرا میشود و گزارشهای تولیدشده برای دانلود در دسترس خواهند بود.
دسترسی به گزارشهای زمانبندیشده
گزارشهای زمانبندیشده به صورت فایلهای CSV ساده تولید میشوند و به طور خودکار و ایمن در فضای ذخیرهسازی ابری گوگل ذخیره میشوند. با این حال، دسترسی مستقیم به مخازن فضای ذخیرهسازی ابری گوگل که حاوی این فایلها هستند، امکانپذیر نیست. در عوض، میتوان فایلها را به صورت دستی از رابط کاربری Display & Video 360 دانلود کرد یا با استفاده از URLهای از پیش مجاز شده که از API دریافت میشوند، به صورت برنامهنویسی بازیابی کرد.
An example of using the API to download a report file is provided below. In this example, queries.reports.list is used with the orderBy parameter to retrieve the most recent report under a query. Then the Report.reportMetadata.googleCloudStoragePath field is used to locate the report file and download its contents to a local CSV file.
جاوا
واردات مورد نیاز:
import com.google.api.client.googleapis.media.MediaHttpDownloader; import com.google.api.client.googleapis.util.Utils; import com.google.api.client.http.GenericUrl; import com.google.api.services.doubleclickbidmanager.DoubleClickBidManager; import com.google.api.services.doubleclickbidmanager.model.ListReportsResponse; import com.google.api.services.doubleclickbidmanager.model.Report; import java.io.FileOutputStream; import java.io.OutputStream;
مثال کد:
long queryId = query-id; // Call the API, listing the reports under the given queryId from most to // least recent. ListReportsResponse reportListResponse = service .queries() .reports() .list(queryId) .setOrderBy("key.reportId desc") .execute(); // Iterate over returned reports, stopping once finding a report that // finished generating successfully. Report mostRecentReport = null; if (reportListResponse.getReports() != null) { for (Report report : reportListResponse.getReports()) { if (report.getMetadata().getStatus().getState().equals("DONE")) { mostRecentReport = report; break; } } } else { System.out.format("No reports exist for query Id %s.\n", queryId); } // Download report file of most recent finished report found. if (mostRecentReport != null) { // Retrieve GCS URL from report object. GenericUrl reportUrl = new GenericUrl(mostRecentReport.getMetadata().getGoogleCloudStoragePath()); // Build filename. String filename = mostRecentReport.getKey().getQueryId() + "_" + mostRecentReport.getKey().getReportId() + ".csv"; // Download the report file. try (OutputStream output = new FileOutputStream(filename)) { MediaHttpDownloader downloader = new MediaHttpDownloader(Utils.getDefaultTransport(), null); downloader.download(reportUrl, output); } System.out.format("Download of file %s complete.\n", filename); } else { System.out.format( "There are no completed report files to download for query Id %s.\n", queryId); }
پایتون
واردات مورد نیاز:
from contextlib import closing from six.moves.urllib.request import urlopen
مثال کد:
query_id = query-id # Call the API, listing the reports under the given queryId from most to # least recent. response = service.queries().reports().list(queryId=query_id, orderBy="key.reportId desc").execute() # Iterate over returned reports, stopping once finding a report that # finished generating successfully. most_recent_report = None if response['reports']: for report in response['reports']: if report['metadata']['status']['state'] == 'DONE': most_recent_report = report break else: print('No reports exist for query Id %s.' % query_id) # Download report file of most recent finished report found. if most_recent_report != None: # Retrieve GCS URL from report object. report_url = most_recent_report['metadata']['googleCloudStoragePath'] # Build filename. output_file = '%s_%s.csv' % (report['key']['queryId'], report['key']['reportId']) # Download the report file. with open(output_file, 'wb') as output: with closing(urlopen(report_url)) as url: output.write(url.read()) print('Download of file %s complete.' % output_file) else: print('There are no completed report files to download for query Id %s.' % query_id)
پی اچ پی
$queryId = query-id; // Call the API, listing the reports under the given queryId from most to // least recent. $optParams = array('orderBy' => "key.reportId desc"); $response = $service->queries_reports->listQueriesReports($queryId, $optParams); // Iterate over returned reports, stopping once finding a report that // finished generating successfully. $mostRecentReport = null; if (!empty($response->getReports())) { foreach ($response->getReports() as $report) { if ($report->metadata->status->state == "DONE") { $mostRecentReport = $report; break; } } } else { printf('<p>No reports exist for query ID %s.</p>', $queryId); } // Download report file of most recent finished report found. if ($mostRecentReport != null) { // Build filename. $filename = $mostRecentReport->key->queryId . '_' . $mostRecentReport->key->reportId . '.csv'; // Download the report file. file_put_contents($filename, fopen($mostRecentReport->metadata->googleCloudStoragePath, 'r')); printf('<p>Download of file %s complete.</p>', $filename); } else { printf('<p>There are no completed report files to download for query Id %s.</p>', $queryId); }