เริ่มต้นใช้งาน
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เอกสารนี้มีไว้สำหรับนักพัฒนาซอฟต์แวร์ที่ต้องการใช้ API การจัดการ AdSense เพื่อรับข้อมูลเกี่ยวกับบัญชี AdSense เอกสารนี้ถือว่าคุณคุ้นเคยกับแนวคิดการเขียนโปรแกรมเว็บและรูปแบบข้อมูลเว็บแล้ว
ก่อนจะเริ่ม
รับบัญชี AdSense
ลงชื่อสมัครใช้หรือลงชื่อเข้าใช้บัญชี AdSense เพื่อเริ่มต้นใช้งาน
ทำความคุ้นเคยกับ AdSense
หากคุณไม่คุ้นเคยกับแนวคิดของ AdSense โปรดอ่านข้อมูลเบื้องต้นเกี่ยวกับ AdSense และทดสอบกับ UI ของ AdSense ก่อนเริ่มเขียนโค้ด
เลือกไลบรารีของไคลเอ็นต์
ในหน้าไลบรารีไคลเอ็นต์และหน้าลองฟัง คุณจะพบข้อมูลเกี่ยวกับไลบรารีและตัวอย่างที่ใช้ได้ คลิกแท็บสำหรับภาษาที่คุณเลือกและคลิกลิงก์เพื่อดาวน์โหลดแหล่งที่มา
ไลบรารีของไคลเอ็นต์จะจัดการสิ่งต่อไปนี้ให้คุณ
- การตรวจสอบสิทธิ์
- การค้นพบบริการ
- การสร้างคำขอไปยัง API
- การแยกวิเคราะห์คำตอบ
อ่านคำแนะนำในการติดตั้งและกำหนดค่าไลบรารีของไคลเอ็นต์ที่เลือก ซึ่งโดยทั่วไปจะอยู่ในไฟล์ README ในไดเรกทอรีรากของที่เก็บ
หากการติดตั้งใช้งานของคุณมีความต้องการพิเศษ เช่น ใช้ภาษาที่ไม่รองรับ คุณจะส่งคำขอโดยตรงไปยัง API แทนการใช้ไลบรารีของไคลเอ็นต์ได้
ลงทะเบียนแอปพลิเคชันของคุณ
หากต้องการใช้ AdSense Management API คุณต้องลงทะเบียนแอปพลิเคชันที่คุณกำลังพัฒนาโดยสร้างโปรเจ็กต์และสร้าง Client-ID
ลงทะเบียนแอป
แก้ไขไฟล์การกำหนดค่าสำหรับโปรเจ็กต์ไลบรารีของไคลเอ็นต์ด้วยข้อมูลเข้าสู่ระบบใหม่ที่คุณเพิ่งสร้าง โปรดดูรายละเอียดเพิ่มเติมในเอกสารประกอบของไลบรารีของไคลเอ็นต์
หมายเหตุ: บัญชี Google ที่ใช้ในการลงทะเบียนควรเป็นบัญชีนักพัฒนาซอฟต์แวร์ กล่าวคือ บัญชีที่คุณต้องการให้ผู้ใช้แอปพลิเคชันเห็นว่าเป็นนักพัฒนาซอฟต์แวร์ของแอปพลิเคชัน บัญชีนี้ไม่จำเป็นต้องเชื่อมโยงกับข้อมูลการเข้าสู่ระบบ AdSense เนื่องจากผู้ใช้จะให้สิทธิ์เข้าถึงบัญชีของตนขณะใช้แอปพลิเคชัน
บทแนะนำการเริ่มต้นอย่างรวดเร็ว
ทำตามขั้นตอนด้านล่างเพื่อส่งคำขอแรก โปรดทราบว่าขั้นตอนเหล่านี้อาจแตกต่างกันไปเล็กน้อย ทั้งนี้ขึ้นอยู่กับไลบรารีหรือภาษาที่คุณใช้
- ใช้ตัวอย่างที่เหมาะสมเพื่อเรียกดูรายการไคลเอ็นต์โฆษณาจาก
บัญชี AdSense คำขอนี้จะเริ่มต้นกระบวนการแบบใช้ครั้งเดียว ซึ่งผู้ใช้ AdSense จะตรวจสอบสิทธิ์และให้สิทธิ์โปรเจ็กต์ของคุณ
ไคลเอ็นต์โฆษณาแสดงถึงการเชื่อมโยงระหว่างบัญชี AdSense กับผลิตภัณฑ์ AdSense เช่น โฆษณาแบบคอนเทนต์หรือโฆษณา Search
บัญชี AdSense มีลูกค้าโฆษณา 1 รายหรือหลายรายก็ได้
- สำหรับเว็บแอปพลิเคชัน ระบบจะเปลี่ยนเส้นทางผู้ใช้ไปยังเว็บไซต์ซึ่ง
จะเลือกให้สิทธิ์เข้าถึงได้ เมื่อให้สิทธิ์แล้ว ระบบจะเปลี่ยนเส้นทางผู้ใช้ไปยัง URL เรียกกลับที่ระบุไว้ในคอนโซล Google API
- แอปพลิเคชันที่ติดตั้งทำงานคล้ายคลึงกัน ไลบรารีของไคลเอ็นต์จะพยายามเปิดหน้าต่างเบราว์เซอร์และใช้รหัสการให้สิทธิ์ สำหรับแอปพลิเคชัน Android, Chrome และ iOS วิธีนี้เป็นวิธีการเฉพาะแพลตฟอร์ม
- ใช้โปรแกรมสำรวจ Google APIs สำหรับ
reports.generate
เพื่อขอรายงานต่อไปนี้
date_range: YESTERDAY
dimensions: DATE
metrics: ESTIMATED_EARNINGS
รายงานให้ข้อมูลเชิงลึกเกี่ยวกับรายได้ที่ได้รับ รวมถึงสิ่งที่ส่งผลต่อรายได้เหล่านั้น ซึ่งสามารถแสดงได้ในทั้งบัญชีหรือกับส่วนย่อยของหน่วยโฆษณาผ่านการใช้แชแนล
- ลองขอรายงานเดียวกันนี้จากแอปพลิเคชันของคุณ
- คุณสามารถกรองรายงานตามหน่วยโฆษณา ดึงข้อมูลรายการหน่วยโฆษณาโดยใช้
adunits.list
โปรดทราบว่าจำเป็นต้องมีรหัสไคลเอ็นต์โฆษณา (ดาวน์โหลดจากขั้นตอนที่ 1) หลังจากเลือกหน่วยโฆษณาแล้ว ให้ใช้รหัสในพารามิเตอร์ตัวกรองสำหรับ reports.generate
ดังนี้
หน่วยโฆษณาคือตัวยึดตำแหน่งที่ผู้ใช้กำหนดค่าเองสำหรับโฆษณา โดยกำหนดพร็อพเพอร์ตี้บางอย่างสำหรับโฆษณาที่แสดง (เช่น ขนาดและรูปร่าง)
date_range: YESTERDAY
dimensions: DATE
metrics: ESTIMATED_EARNINGS
filter: AD_UNIT_ID==ca-pub-123456789:987654321
- ลองกรองตามแชแนลที่กำหนดเองหรือแชแนล URL หรือใช้ตัวกรองหลายรายการผสมกัน
แชแนลเป็นเครื่องมือที่ช่วยให้คุณติดตาม
ประสิทธิภาพของหน่วยโฆษณาชุดย่อยได้ แชแนลมี 2 ประเภท ได้แก่ URL และแชแนลที่กำหนดเอง โหมดความยินยอมช่วยให้คุณติดตามประสิทธิภาพในหน้าเว็บหรือโดเมนที่เจาะจง ขณะที่ตัวเลือกหลังช่วยให้คุณติดตามประสิทธิภาพของหน่วยโฆษณากลุ่มใดกลุ่มหนึ่งที่ผู้ใช้เลือก
คุณพร้อมเริ่มต้นใช้งานแล้วด้วยการสำรวจการโทรและแหล่งข้อมูลอื่นๆ ที่มีอยู่ในเอกสารอ้างอิง
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-31 UTC
[null,null,["อัปเดตล่าสุด 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)."]]