開始使用
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本文件適用於想要透過 AdSense Management API 取得 AdSense 帳戶相關資訊的開發人員,本文假設您熟悉網路程式設計概念和網路資料格式。
事前準備
取得 AdSense 帳戶
註冊或登入 AdSense 帳戶即可開始體驗。
熟悉 AdSense
如果您還不熟悉 AdSense 概念,請參閱 AdSense 簡介資訊並測試 AdSense UI,然後再開始寫程式。
選擇您的用戶端程式庫
您可以在用戶端程式庫與範例頁面中找到可用程式庫與範例的相關資訊。按一下所選語言的分頁標籤,點選連結即可下載來源。用戶端程式庫會為您處理下列項目:
請參閱安裝及設定所選用戶端程式庫的操作說明,通常位於存放區根目錄的 README 檔案中。
如果您的實作有特殊需求 (例如使用不支援的語言),您可以向 API 直接發出要求,而非使用用戶端程式庫。
註冊應用程式
若要使用 AdSense Management API,您必須建立專案並產生用戶端 ID,以註冊您正在開發的應用程式。
註冊應用程式
使用您剛建立的新憑證,編輯用戶端程式庫專案的設定檔。詳情請參閱用戶端程式庫說明文件。
注意:註冊時使用的 Google 帳戶應為您的「開發人員」帳戶,也就是您希望應用程式使用者顯示為應用程式開發人員的帳戶。這個帳戶不需要與 AdSense 登入資訊連結,因為使用者會在使用應用程式時授予自身帳戶的存取權。
快速入門教學課程
請按照下列步驟提出第一個要求,請注意,視您使用的程式庫或語言而定,這些步驟可能略有不同:
- 請使用適當的範例,從 AdSense 帳戶擷取廣告用戶端清單。這項要求會啟動一次性的程序,由 AdSense 使用者驗證並授權您的專案。
廣告用戶端代表 AdSense 帳戶與 AdSense 產品之間的關聯,例如多媒體廣告或搜尋廣告。AdSense 帳戶可以有一個或多個廣告用戶端。
- 如果是網頁應用程式,系統會將使用者重新導向至可供他們選擇授予存取權的網站。取得授權後,系統會將其重新導向至 Google API 控制台中定義的回呼網址。
- 已安裝的應用程式以類似的方式運作。用戶端程式庫會嘗試開啟瀏覽器視窗,並使用授權碼。在 Android、Chrome 和 iOS 應用程式上,這種做法適用於特定平台。
- 使用
reports.generate
的 Google API 多層檢視提出下列報表要求:
date_range: YESTERDAY
dimensions: DATE
metrics: ESTIMATED_EARNINGS
報表可讓您查看收益資料,以及這些收益的影響因素。使用管道,您就能針對整個帳戶或一小部分的廣告單元執行報表。
- 試著在應用程式中請求相同的報表。
- 您可以按廣告單元篩選報表。使用
adunits.list
擷取廣告單元清單。請注意,您必須使用廣告用戶端 ID (從步驟 1 取得)。選擇廣告單元後,請在 reports.generate
的 filter 參數中使用其 ID:
廣告單元是指使用者為廣告設定的預留位置,其定義了顯示廣告的部分屬性 (如大小與形狀)。
date_range: YESTERDAY
dimensions: DATE
metrics: ESTIMATED_EARNINGS
filter: AD_UNIT_ID==ca-pub-123456789:987654321
- 請嘗試按自訂或網址管道進行篩選,或合併多個篩選條件。
您可以使用管道這項工具來追蹤一小部分廣告單元的成效,管道類型有兩種:網址和自訂。前者可讓您追蹤某個網頁或網域的成效,後者則可讓您追蹤使用者所選特定廣告單元群組的成效。
請瀏覽在參考說明文件中其他可用的呼叫和資源,即可開始實作。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[null,null,["上次更新時間:2025-08-31 (世界標準時間)。"],[[["\u003cp\u003eStarts ADH import of a specified BigQuery table containing a quarterly brand lift benchmark report, triggered by the customer.\u003c/p\u003e\n"],["\u003cp\u003eRequires specifying the year, quarter, and source BigQuery table in the request body.\u003c/p\u003e\n"],["\u003cp\u003eUses POST request to \u003ccode\u003ehttps://adsdatahub.googleapis.com/v1/{customer=customers/*}:submitBrandLiftBenchmark\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eNeeds \u003ccode\u003ehttps://www.googleapis.com/auth/adsdatahub\u003c/code\u003e authorization scope.\u003c/p\u003e\n"],["\u003cp\u003eReturns an Operation object upon successful submission.\u003c/p\u003e\n"]]],["To use the AdSense Management API, first, obtain an AdSense account and familiarize yourself with it. Select a client library or make direct API requests. Register your application to get a Client ID, and configure your project with the credentials. Retrieve a list of ad clients, then generate reports using the API explorer or your application. Filter reports by ad units or channels, and explore the API reference documentation to start implementing your code.\n"],null,["# Get Started\n\nThis document is for developers who want to use the AdSense Management API to get\ninformation about their AdSense account. This document assumes that you're\nfamiliar with web programming concepts and web data formats.\n\nBefore you start\n----------------\n\n### Get an AdSense account\n\nSign up or sign in to your [AdSense\naccount](//adsense.google.com/) to get started.\n\n### Get familiar with AdSense\n\nIf you're not familiar with AdSense concepts read the [introductory information on AdSense](//support.google.com/adsense)\nand experiment with the [AdSense UI](//adsense.google.com/)\nbefore starting to code.\n\n### Choose your client library\n\nIn the [Client Libraries and Samples\npage](/adsense/management/libraries), you'll find information on the available libraries and samples. Click\nthe tab for your chosen language and follow the links to download the source.\nThe client libraries handle the following for you:\n\n- authentication\n- discovery of services\n- building the requests to the API\n- response parsing\n\nRead the instructions to install and configure your chosen client library,\ntypically found in the README file in the root directory of the repository.\n\nIf your implementation has special needs, such as using an unsupported\nlanguage, you can [make direct\nrequests](/adsense/management/direct_requests) to the API instead of using a client library.\n\nRegister your application\n-------------------------\n\nTo use the AdSense Management API you must register the application you're developing\nby creating a project and generating a Client ID.\nRegister your app\n\nEdit the configuration files for your client library project with the new\ncredentials you just created. Check the client library documentation for more\ndetails.\n\n**Note:** The Google Account used for registration should be\nyour **developer** account, that is, the account that you want users of your\napplication to see as the developer of the application. **This account does\nnot need to be tied to an AdSense login**, as users will be granting access\nto their own accounts while using the application.\n\nQuick start tutorial\n--------------------\n\nFollow the steps below to make your first requests, note that these steps\nmay vary slightly depending on the library or language you are using:\n\n1. Use the appropriate sample to retrieve a list of ad clients from an AdSense account. This request initiates a one-time process in which the AdSense user authenticates and authorizes your project. **Ad clients** represent an association between an\n AdSense account and an AdSense product, such as Content Ads or Search Ads.\n An AdSense account can have one or multiple ad clients.\n\n 1. For **web applications**, users will be redirected to a site where they can choose to grant access. Once authorized, they will be redirected to the callback URL defined in the Google API Console.\n 2. **Installed applications** work similarly. The client library will try to open a browser window and use an authorization code. For Android, Chrome and iOS applications this method is platform-specific.\n2. Use the [Google APIs explorer for\n `reports.generate`](/adsense/management/reference/rest/v2/accounts.reports/generate) to request the following report:\n - `date_range: YESTERDAY`\n - `dimensions: DATE`\n - `metrics: ESTIMATED_EARNINGS`\n\n **Reports** give you insight into what you're earning,\n as well as what's having an impact on those earnings. They can be run on\n an entire account or on a subset of ad units, through the use of\n channels.\n3. Try to request the same report from your application.\n4. You can filter the reports by ad units. Fetch the list of ad units using [adunits.list](/adsense/management/reference/rest/v2/accounts.adclients.adunits/list). Note that an ad client ID is needed (get it from step 1). After you choose an ad unit, use its ID in the [filter](/adsense/management/reporting/filtering) parameter for `reports.generate`:\n\n **Ad Units** are user-configured placeholders for ads,\n that define some properties for the ads being shown (such as size and\n shape).\n - `date_range: YESTERDAY`\n - `dimensions: DATE`\n - `metrics: ESTIMATED_EARNINGS`\n - `filter: AD_UNIT_ID==ca-pub-123456789:987654321`\n5. Try filtering by custom or URL channels or mixing multiple filters. **Channels** are tools that let you track the\n performance of a subset of your ad units. There are two types of channels:\n URL and custom. The former lets you track performance across a specific\n page or domain, whereas the latter help you track performance on specific\n user-selected groups of ad units.\n\nYou are ready to start your implementation by exploring the rest of the\navailable calls and resources in the [reference\ndocumentation](/adsense/management/reference/rest)."]]