DoubleClick Bid Manager 서비스를 사용하면 Apps Script에서 DV360 Bid Manager API를 사용할 수 있습니다. 이 API는 DoubleClick Bid Manager (DBM) 보고에 대한 프로그래매틱 액세스를 제공합니다.
참조
이 서비스에 대한 자세한 내용은 DBM Reporting API의 참조 문서를 참고하세요. Apps Script의 모든 고급 서비스와 마찬가지로 DoubleClick Bid Manager 서비스는 공개 API와 동일한 객체, 메서드, 매개변수를 사용합니다. 자세한 내용은 메서드 서명이 결정되는 방식을 참고하세요.
/** * Logs all of the queries available in the account. */functionlistQueries(){// Retrieve the list of available queriestry{constqueries=DoubleClickBidManager.Queries.list();if(queries.queries){// Print out the ID and name of eachfor(leti=0;i < queries.queries.length;i++){constquery=queries.queries[i];console.log('Found query with ID %s and name "%s".',query.queryId,query.metadata.title);}}}catch(e){// TODO (Developer) - Handle exceptionconsole.log('Failed with error: %s',e.error);}}
/** * Create and run a new DBM Query */functioncreateAndRunQuery(){letresult;letexecution;//We leave the default date range blank for the report run to//use the value defined during query creationletdefaultDateRange={}letpartnerId="1234567"//Replace with your Partner IDletquery={"metadata":{"title":"Apps Script Example Report","dataRange":{"range":"YEAR_TO_DATE"},"format":"CSV"},"params":{"type":"STANDARD","groupBys":["FILTER_PARTNER","FILTER_PARTNER_NAME","FILTER_ADVERTISER","FILTER_ADVERTISER_NAME",],"filters":[{"type":"FILTER_PARTNER","value":partnerId}],"metrics":["METRIC_IMPRESSIONS"]},"schedule":{"frequency":"ONE_TIME"}}try{result=DoubleClickBidManager.Queries.create(query);if(result.queryId){console.log('Created query with ID %s and name "%s".',result.queryId,result.metadata.title);execution=DoubleClickBidManager.Queries.run(defaultDateRange,result.queryId);if(execution.key){console.log('Created query report with query ID %s and report ID "%s".',execution.key.queryId,execution.key.reportId);}}}catch(e){// TODO (Developer) - Handle exceptionconsole.log(e)console.log('Failed with error: %s',e.error);}}
/** * Fetches a report file */functionfetchReport(){constqueryId='1234567';// Replace with your query ID.constorderBy="key.reportId desc";try{constreport=DoubleClickBidManager.Queries.Reports.list(queryId,{orderBy:orderBy});if(report.reports){constfirstReport=report.reports[0];if(firstReport.metadata.status.state=='DONE'){constreportFile=UrlFetchApp.fetch(firstReport.metadata.googleCloudStoragePath)console.log("Printing report content to log...")console.log(reportFile.getContentText())}else{console.log("Report status is %s, and is not available for download",firstReport.metadata.status.state)}}}catch(e){// TODO (Developer) - Handle exceptionconsole.log(e)console.log('Failed with error: %s',e.error);}}
[null,null,["최종 업데이트: 2025-08-31(UTC)"],[],[],null,["# DoubleClick Bid Manager Service\n\nThe DoubleClick Bid Manager service lets you use the\n[DV360 Bid Manager API](/bid-manager)\nin Apps Script. This API provides programmatic access to DoubleClick Bid\nManager (DBM) Reporting.\n| **Note:** This is an advanced service that must be [enabled before use](/apps-script/guides/services/advanced).\n\nReference\n---------\n\nFor detailed information on this service, see the\n[reference documentation](/bid-manager/reference/rest) for the\nDBM Reporting API. Like all advanced services in Apps\nScript, the DoubleClick Bid Manager service uses the same objects, methods, and\nparameters as the public API. For more information, see [How method signatures are determined](/apps-script/guides/services/advanced#how_method_signatures_are_determined).\n\nTo report issues and find other support, see the\n[DBM Reporting and Trafficking support guide](/bid-manager/support).\n\nSample code\n-----------\n\nThe following sample code uses\n[version 2](/bid-manager/reference/rest) of the API.\n\n### Get a list of queries\n\nThis sample logs all of the queries available in the account. \nadvanced/doubleclickbidmanager.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/doubleclickbidmanager.gs) \n\n```javascript\n/**\n * Logs all of the queries available in the account.\n */\nfunction listQueries() {\n // Retrieve the list of available queries\n try {\n const queries = DoubleClickBidManager.Queries.list();\n\n if (queries.queries) {\n // Print out the ID and name of each\n for (let i = 0; i \u003c queries.queries.length; i++) {\n const query = queries.queries[i];\n console.log('Found query with ID %s and name \"%s\".',\n query.queryId, query.metadata.title);\n }\n }\n } catch (e) {\n // TODO (Developer) - Handle exception\n console.log('Failed with error: %s', e.error);\n }\n}\n```\n\n### Create and run a query\n\nThis sample creates and runs a new DBM query. \nadvanced/doubleclickbidmanager.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/doubleclickbidmanager.gs) \n\n```javascript\n/**\n * Create and run a new DBM Query\n */\nfunction createAndRunQuery() {\n let result;\n let execution;\n //We leave the default date range blank for the report run to\n //use the value defined during query creation\n let defaultDateRange = {}\n let partnerId = \"1234567\" //Replace with your Partner ID\n let query = {\n \"metadata\": {\n \"title\": \"Apps Script Example Report\",\n \"dataRange\": {\n \"range\": \"YEAR_TO_DATE\"\n },\n \"format\": \"CSV\"\n },\n \"params\": {\n \"type\": \"STANDARD\",\n \"groupBys\": [\n \"FILTER_PARTNER\",\n \"FILTER_PARTNER_NAME\",\n \"FILTER_ADVERTISER\",\n \"FILTER_ADVERTISER_NAME\",\n ],\n \"filters\": [\n {\"type\": \"FILTER_PARTNER\",\"value\": partnerId}\n ],\n \"metrics\": [\n \"METRIC_IMPRESSIONS\"\n ]\n },\n \"schedule\": {\n \"frequency\": \"ONE_TIME\"\n }\n }\n\n try {\n result = DoubleClickBidManager.Queries.create(query);\n if (result.queryId) {\n console.log('Created query with ID %s and name \"%s\".',\n result.queryId, result.metadata.title);\n execution = DoubleClickBidManager.Queries.run(defaultDateRange, result.queryId);\n if(execution.key){\n console.log('Created query report with query ID %s and report ID \"%s\".',\n execution.key.queryId, execution.key.reportId);\n }\n }\n } catch (e) {\n // TODO (Developer) - Handle exception\n console.log(e)\n console.log('Failed with error: %s', e.error);\n }\n}\n```\n\n### Fetch the most recent report for a DBM query\n\nThis sample fetches the most recent report for a DBM query and logs the content. \nadvanced/doubleclickbidmanager.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/doubleclickbidmanager.gs) \n\n```javascript\n/**\n * Fetches a report file\n */\nfunction fetchReport() {\n const queryId = '1234567'; // Replace with your query ID.\n const orderBy = \"key.reportId desc\";\n\n try {\n const report = DoubleClickBidManager.Queries.Reports.list(queryId, {orderBy:orderBy});\n if(report.reports){\n const firstReport = report.reports[0];\n if(firstReport.metadata.status.state == 'DONE'){\n const reportFile = UrlFetchApp.fetch(firstReport.metadata.googleCloudStoragePath)\n console.log(\"Printing report content to log...\")\n console.log(reportFile.getContentText())\n }\n else{\n console.log(\"Report status is %s, and is not available for download\", firstReport.metadata.status.state)\n }\n }\n\n } catch (e) {\n // TODO (Developer) - Handle exception\n console.log(e)\n console.log('Failed with error: %s', e.error);\n }\n}\n```"]]