Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Tài liệu này dành cho những nhà phát triển muốn sử dụng API Quản lý AdSense để nhận
thông tin về tài khoản AdSense của họ. Tài liệu này giả định rằng bạn đã quen thuộc với các khái niệm lập trình web và định dạng dữ liệu web.
Trước khi bắt đầu
Đăng ký tài khoản AdSense
Để bắt đầu, hãy đăng ký hoặc đăng nhập vào tài khoản
AdSense của bạn.
Trên trang Thư viện ứng dụng và Mẫu, bạn sẽ tìm thấy thông tin về các thư viện và mẫu có sẵn. Nhấp vào thẻ tương ứng với ngôn ngữ bạn chọn và truy cập vào các đường liên kết để tải nguồn xuống.
Thư viện ứng dụng xử lý những việc sau cho bạn:
xác thực
khám phá dịch vụ
tạo các yêu cầu đến API
phân tích cú pháp phản hồi
Đọc hướng dẫn để cài đặt và định cấu hình thư viện ứng dụng mà bạn chọn, thường có trong tệp README trong thư mục gốc của kho lưu trữ.
Nếu quá trình triển khai của bạn có nhu cầu đặc biệt, chẳng hạn như sử dụng một ngôn ngữ không được hỗ trợ, thì bạn có thể đưa ra yêu cầu trực tiếp đến API thay vì sử dụng thư viện ứng dụng.
Đăng ký ứng dụng của bạn
Để sử dụng API Quản lý AdSense, bạn phải đăng ký ứng dụng mà mình đang phát triển
bằng cách tạo một dự án và tạo một Mã ứng dụng khách.
Chỉnh sửa tệp cấu hình cho dự án thư viện ứng dụng bằng thông tin xác thực mới mà bạn vừa tạo. Hãy xem tài liệu về thư viện ứng dụng để biết thêm thông tin chi tiết.
Lưu ý: Tài khoản Google dùng để đăng ký phải là tài khoản nhà phát triển của bạn, tức là tài khoản mà bạn muốn người dùng ứng dụng xem với tư cách là nhà phát triển ứng dụng. Tài khoản này không cần phải liên kết với thông tin đăng nhập AdSense, vì người dùng sẽ được cấp quyền truy cập vào tài khoản của riêng họ trong khi sử dụng ứng dụng.
Hướng dẫn bắt đầu nhanh
Hãy làm theo các bước bên dưới để đưa ra yêu cầu đầu tiên của bạn, xin lưu ý rằng các bước này có thể khác nhau đôi chút tuỳ thuộc vào thư viện hoặc ngôn ngữ bạn đang sử dụng:
Hãy sử dụng mẫu thích hợp để truy xuất danh sách ứng dụng quảng cáo từ một
tài khoản AdSense. Yêu cầu này sẽ bắt đầu quy trình một lần, trong đó người dùng AdSense sẽ xác thực và uỷ quyền cho dự án của bạn.
Ứng dụng quảng cáo đại diện cho mối liên kết giữa tài khoản AdSense và sản phẩm AdSense, chẳng hạn như Quảng cáo nội dung hoặc Quảng cáo Tìm kiếm.
Một tài khoản AdSense có thể có một hoặc nhiều ứng dụng quảng cáo.
Đối với các ứng dụng web, người dùng sẽ được chuyển hướng đến một trang web mà họ có thể chọn cấp quyền truy cập. Sau khi được cấp quyền, họ sẽ được chuyển hướng
đến URL gọi lại được xác định trong Bảng điều khiển API của Google.
Các ứng dụng đã cài đặt hoạt động tương tự như vậy. Thư viện ứng dụng sẽ cố mở một cửa sổ trình duyệt và dùng mã uỷ quyền. Đối với các ứng dụng Android, Chrome và iOS, phương thức này dành riêng cho từng nền tảng.
Báo cáo cung cấp cho bạn thông tin chi tiết về thu nhập của bạn
cũng như những yếu tố tác động đến các khoản thu nhập đó. Bạn có thể chạy những quảng cáo này trên
toàn bộ tài khoản hoặc trên một số đơn vị quảng cáo, thông qua việc sử dụng
các kênh.
Hãy thử yêu cầu ứng dụng của bạn cung cấp cùng một báo cáo.
Bạn có thể lọc báo cáo theo đơn vị quảng cáo. Tìm nạp danh sách đơn vị quảng cáo bằng cách sử dụng adunits.list.
Xin lưu ý rằng bạn cần có mã ứng dụng khách quảng cáo (lấy mã này từ bước 1). Sau khi bạn chọn
một đơn vị quảng cáo, hãy sử dụng mã đơn vị quảng cáo đó trong thông số
filter cho
reports.generate:
Đơn vị quảng cáo là phần giữ chỗ do người dùng định cấu hình cho quảng cáo,
xác định một số thuộc tính cho quảng cáo sẽ hiển thị (chẳng hạn như kích thước và
hình dạng).
date_range: YESTERDAY
dimensions: DATE
metrics: ESTIMATED_EARNINGS
filter: AD_UNIT_ID==ca-pub-123456789:987654321
Hãy thử lọc theo kênh tuỳ chỉnh hay kênh URL hoặc kết hợp nhiều bộ lọc.
Kênh là công cụ cho phép bạn theo dõi
hiệu suất của một tập hợp con đơn vị quảng cáo. Có hai loại kênh:
URL và kênh tuỳ chỉnh. Tùy chọn cài đặt trước giúp bạn theo dõi hiệu suất trên một
trang hoặc miền cụ thể, trong khi phần sau giúp bạn theo dõi hiệu suất trên các nhóm đơn vị quảng cáo cụ thể
do người dùng chọn.
Bạn có thể bắt đầu triển khai bằng cách khám phá các lệnh gọi và tài nguyên còn lại trong tài liệu tham khảo.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-08-31 UTC."],[[["\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)."]]