Để thảo luận và đưa ra ý kiến phản hồi về các sản phẩm của chúng tôi, hãy tham gia kênh Discord chính thức của Google Ads trong máy chủ Cộng đồng quảng cáo và đo lường của Google.
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.
Trong bước này, bạn xác định một tài khoản Google Ads để thực hiện lệnh gọi API. Tài khoản này có thể là tài khoản chính thức (đang hoạt động) hoặc tài khoản thử nghiệm. Mỗi phương pháp đều có ưu và nhược điểm riêng.
Tài khoản sản xuất
Tài khoản thử nghiệm
Ưu điểm
Dễ dàng viết và kiểm thử mã hoạt động với nội dung cụ thể của tài khoản.
Dễ dàng viết và kiểm thử mã xử lý dữ liệu báo cáo trực tiếp.
Tài khoản thử nghiệm không phân phát quảng cáo, do đó, lỗi lập trình sẽ không ảnh hưởng đến các chiến dịch đang hoạt động của bạn.
Hoạt động với mã thông báo nhà phát triển có cấp Quyền truy cập thử nghiệm.
Nhược điểm
Lỗi lập trình trong giai đoạn phát triển có thể ảnh hưởng đến việc phân phát chiến dịch đang hoạt động, dẫn đến các vấn đề như hiệu suất chiến dịch kém, phân phát không chính xác hoặc tổn thất tài chính.
Mã thông báo nhà phát triển phải có ít nhất cấp truy cập cơ bản để có thể thực hiện lệnh gọi API.
Bạn phải tạo lại chiến dịch trong tài khoản thử nghiệm để kiểm thử mã hoạt động với nội dung cụ thể của tài khoản.
Vì tài khoản thử nghiệm không phân phát quảng cáo nên các tính năng liên quan đến việc phân phát trực tiếp (chẳng hạn như báo cáo số liệu thống kê, lỗi vi phạm chính sách hoặc xử lý lượt chuyển đổi ngoại tuyến) sẽ không được hỗ trợ, khiến bạn khó kiểm thử các tính năng đó.
Bạn nên sử dụng tài khoản thử nghiệm trong khi phát triển ứng dụng khi có thể. Để xem hướng dẫn, hãy xem bài viết Tạo tài khoản và chiến dịch thử nghiệm.
Một giải pháp khác là thiết lập tài khoản chính thức có ngân sách tài khoản thấp, chẳng hạn như 1 đô la/ngày, rõ ràng là để thử nghiệm các tính năng mà tài khoản thử nghiệm không hỗ trợ.
Lựa chọn bộ tính năng
Khi chọn một tài khoản để thực hiện lệnh gọi API, bạn cần cân nhắc thêm danh sách các tính năng mà bạn muốn sử dụng với API. Ngay cả khi bạn chọn sử dụng tài khoản phát hành công khai, vẫn có một số tính năng dành riêng cho tài khoản, chẳng hạn như:
Để sử dụng các tính năng thanh toán, bạn cần có một tài khoản sử dụng phương thức lập hoá đơn hằng tháng.
Một số tính năng mới trong tài khoản có thể bị hạn chế theo danh sách cho phép.
Trước khi hoàn tất tài khoản để thực hiện lệnh gọi API, hãy kiểm tra tài liệu về tính năng cụ thể để đảm bảo rằng tính năng đó không có thêm quy định hạn chế nào.
Xác định mã khách hàng đăng nhập và mã khách hàng
Để thực hiện lệnh gọi API cho một khách hàng Google Ads, bạn phải cấp quyền truy cập và các quyền thích hợp cho tài khoản dịch vụ của mình cho tài khoản khách hàng trực tiếp hoặc thông qua tài khoản người quản lý được liên kết. Để làm việc này, bạn cần có quyền quản trị đối với tài khoản khách hàng.
Bắt đầu bằng cách đăng nhập vào tài khoản Google Ads của bạn với tư cách là quản trị viên. Trong một số trường hợp, bạn có thể có nhiều tài khoản khách hàng để chọn. Tài khoản bạn chọn sẽ thiết lập mã khách hàng đăng nhập. Đây là tiêu đề bắt buộc cho một số lệnh gọi API.
Sau khi bạn xác định khách hàng Google Ads để thực hiện lệnh gọi API, hãy lưu ý các thông tin chi tiết sau:
Mã khách hàng gồm 10 chữ số của tài khoản khách hàng mà bạn dự định thực hiện lệnh gọi API. Đôi khi, khách hàng này được gọi là khách hàng vận hành.
Mã khách hàng đăng nhập gồm 10 chữ số của tài khoản khách hàng mà bạn đang đăng nhập. Nếu bạn đã đăng nhập vào khách hàng vận hành, thì mã khách hàng đăng nhập sẽ giống với mã khách hàng. Nếu bạn đã đăng nhập vào tài khoản người quản lý của khách hàng vận hành, thì mã khách hàng đăng nhập sẽ là mã khách hàng của tài khoản người quản lý.
Cấp quyền truy cập vào tài khoản dịch vụ
Khi đăng nhập vào tài khoản Google Ads với tư cách là quản trị viên, hãy chuyển đến mục Quản trị > Quyền truy cập và bảo mật.
Nhấp vào nút + trong thẻ Người dùng.
Nhập địa chỉ email của tài khoản dịch vụ vào hộp nhập Email. Chọn cấp truy cập tài khoản phù hợp rồi nhấp vào nút Thêm tài khoản. Xin lưu ý rằng tài khoản dịch vụ không được hỗ trợ cấp truy cập Email.
Tài khoản dịch vụ được cấp quyền truy cập.
Theo mặc định, bạn không thể cấp quyền quản trị cho tài khoản dịch vụ. Nếu các lệnh gọi API của bạn yêu cầu quyền truy cập của quản trị viên, bạn có thể nâng cấp quyền truy cập như sau.
Nhấp vào mũi tên thả xuống bên cạnh cấp truy cập của tài khoản dịch vụ trong cột Cấp truy cập.
[[["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-21 UTC."],[[["\u003cp\u003eChoose a Google Ads account (production or test) to make API calls, noting its email address for generating OAuth 2.0 refresh tokens.\u003c/p\u003e\n"],["\u003cp\u003eTest accounts are recommended for development to prevent affecting live campaigns; however, they don't support features related to live serving.\u003c/p\u003e\n"],["\u003cp\u003eProduction accounts, with a low budget, can be used to test features unsupported by test accounts, but a programming bug can affect live campaigns.\u003c/p\u003e\n"],["\u003cp\u003eEnsure the selected account supports the desired features as some features have account-specific restrictions.\u003c/p\u003e\n"],["\u003cp\u003eTo make API calls, you need access to the customer account, the 10-digit customer ID, email address for OAuth 2.0 token generation, and the 10-digit login customer ID.\u003c/p\u003e\n"]]],[],null,["**Note:** The current step of this tutorial depends on the [type of application](/google-ads/api/docs/get-started/choose-application-type) you are building. We strongly recommend using service account to make API calls. However, the user authentication option is also provided as an alternative. The rest of this tutorial will be customized based on your choice. \nService accounts User authentication\n\nIn this step, you identify a Google Ads account to make API calls to. The account\ncan either be a production (live) account or a test account. Each approach has\nits advantages and disadvantages.\n\n|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | Production accounts | Test accounts |\n| Advantages | - Easier to write and test code that works against specific account contents. - Easier to write and test code that processes live reporting data. | - Test accounts *don't* serve ads, hence programming bugs won't affect your live campaigns. - Works with developer tokens that have Test Access level. |\n| Disadvantages | - A programming bug in the development phase could affect live campaign serving, leading to issues such as poor campaign performance, incorrect serving, or financial losses. - The developer token should have at least the Basic Access level to in order to make API calls. | - You must reconstruct campaigns within test accounts to test code that works against specific account contents. - Since test accounts don't serve ads, features related to live serving such as reporting stats, policy violation errors, or processing offline conversion imports are not supported, making it difficult to test those features. |\n\nWe recommend using a test account while developing your application when\npossible. For instructions, see [Create test accounts and\ncampaigns](/google-ads/api/docs/best-practices/test-accounts#create).\n\nAn alternative is to set up a production account with a low account budget,\nsuch as $1/day, explicitly for testing features that are not supported by a\ntest account.\n\nChoice of feature set\n\nWhen choosing an account for making API call, an additional consideration is\nthe list of features you'd want to use with the API. Even if you choose to use\na production account, there are some features that are account-specific, for\nexample:\n\n- For billing features, you need an account that is on monthly invoicing.\n- Some new features in the account might be restricted by allowlists.\n\nBefore finalizing the account to make API calls against, check the\ndocumentation of the specific feature to make sure that the feature doesn't\nhave additional restrictions.\n\nIdentify the login customer ID and customer ID\n\nTo make an API call to a Google Ads customer, you must grant access and\nappropriate permissions to your service account to the customer account\neither directly or through a linked manager account. To do this, you need\nadministrator access to the customer account.\n\nStart by signing in to your Google Ads account as an administrator. In some cases,\nyou might have more than one customer account to choose from. The account you\nselect establishes the login customer ID, which is a required header for some\nAPI calls.\n\nAfter you've identified the Google Ads customer to make API calls to, note the\nfollowing details:\n\n- The 10-digit customer ID of the customer account to which you plan to make\n API calls against. This is sometimes referred to as the operating customer.\n\n- The 10-digit login customer ID of the customer account you're signed in to.\n If you're signed in to the operating customer, the login customer ID is the\n same as the customer ID. If you signed into a manager account of the\n operating customer, the login customer ID is the customer ID of the manager\n account.\n\nGrant access to the service account\n\n1. While signed in to your Google Ads account as an administrator, navigate to\n **Admin \\\u003e Access and security**.\n\n2. Click the **+** button under the **Users** tab.\n\n3. Type the service account email address into the **Email** input box. Select\n the appropriate level of account access level and click the **Add account**\n button. Note that Email access level is not supported for service accounts.\n\n4. The service account is granted access.\n\nBy default, you cannot grant administrator access to a service account. If your\nAPI calls require administrator access, you can upgrade the access as follows.\n\n1. Click the drop-down arrow next to the access level of the service account\n in the **Access level** column.\n\n2. Select **Admin** from the drop-down list."]]