Cách quản lý tài khoản và tạo khách hàng mới trong Google Ads API

Ảnh đại diện của Cách quản lý tài khoản và tạo khách hàng mới trong Google Ads API

Quản lý tài khoản hiệu quả là yếu tố quan trọng trong việc triển khai các chiến dịch quảng cáo thành công trên Google Ads. Với Google Ads API, bạn có thể tạo tài khoản mới, quản lý hệ phân cấp tài khoản, và tùy chỉnh quyền truy cập một cách dễ dàng. Trong bài viết này, chúng tôi sẽ hướng dẫn chi tiết cách sử dụng Google Ads API để tạo tài khoản khách hàng mới, liên kết tài khoản với tài khoản người quản lý, và thực hiện các thao tác quản lý quan trọng khác. Đừng bỏ lỡ cơ hội khám phá cách tối ưu hóa quy trình quản lý tài khoản quảng cáo của bạn!

API Google Ads cung cấp khả năng tạo lập tài khoản mới, quản lý hệ thống phân cấp tài khoản và cấu hình các tùy chọn liên quan đến quyền truy cập ở cấp độ tài khoản một cách tự động và hiệu quả.

Để tìm hiểu sâu hơn về các chức năng này, hãy tham khảo các hướng dẫn sau:

  • Tạo tài khoản: Hướng dẫn chi tiết cách tạo tài khoản khách hàng mới trong hệ thống phân cấp tài khoản Google Ads.
  • Liên kết với tài khoản người quản lý: Hướng dẫn cách thêm tài khoản hiện có vào danh sách tài khoản con của tài khoản người quản lý.
  • Liệt kê tài khoản: Hướng dẫn cách liệt kê tất cả các tài khoản mà bạn có quyền truy cập dựa trên thông tin đăng nhập hiện tại.
  • Nhận hệ phân cấp tài khoản: Hướng dẫn cách truy xuất và xem hệ thống phân cấp của tài khoản người quản lý.
  • Quản lý quyền truy cập của người dùng: Hướng dẫn cách cấu hình và quản lý quyền truy cập của người dùng vào tài khoản khách hàng trong Google Ads.

API Google Ads cung cấp khả năng tạo tài khoản mới một cách lập trình, giúp bạn dễ dàng quản lý các tài khoản trong hệ thống phân cấp. Để tạo tài khoản, bạn sẽ cần sử dụng phương thức CreateCustomerClient trong CustomerService. Không giống như các thao tác đột biến thông thường, phương thức này yêu cầu chỉ định ID khách hàng của tài khoản người quản lý sẽ quản lý tài khoản mới được tạo, thay vì sử dụng ID của tài khoản hiện tại.

Dưới đây là một ví dụ chi tiết về cách tạo tài khoản mới bằng các ngôn ngữ lập trình khác nhau:

Java

private void runExample(GoogleAdsClient googleAdsClient, Long managerId) {
String dateTime = ZonedDateTime.now().format(DateTimeFormatter.RFC_1123_DATE_TIME);
// Tạo đối tượng Customer mới
Customer customer = Customer.newBuilder()
.setDescriptiveName(“Account created with CustomerService on ‘” + dateTime + “‘”)
.setCurrencyCode(“USD”)
.setTimeZone(“America/New_York”)
.setTrackingUrlTemplate(“{lpurl}?device={device}”)
.setFinalUrlSuffix(“keyword={keyword}&matchtype={matchtype}&adgroupid={adgroupid}”)
.build();

// Gửi yêu cầu tạo tài khoản khách hàng
try (CustomerServiceClient client = googleAdsClient.getLatestVersion().createCustomerServiceClient()) {
CreateCustomerClientResponse response = client.createCustomerClient(managerId.toString(), customer);
System.out.printf(“Created a customer with resource name ‘%s’ under the manager account with customer ID ‘%d’.%n”,
response.getResourceName(), managerId);
}
}

C#

public void Run(GoogleAdsClient client, long managerCustomerId) {
CustomerServiceClient customerService = client.GetService(Services.V17.CustomerService);
Customer customer = new Customer {
DescriptiveName = $”Account created with CustomerService on ‘{DateTime.Now}‘”,
CurrencyCode = “USD”,
TimeZone = “America/New_York”,
TrackingUrlTemplate = “{lpurl}?device={device}”,
FinalUrlSuffix = “keyword={keyword}&matchtype={matchtype}&adgroupid={adgroupid}”
};

try {
CreateCustomerClientResponse response = customerService.CreateCustomerClient(managerCustomerId.ToString(), customer);
Console.WriteLine($”Created a customer with resource name ‘{response.ResourceName}‘ under the manager account with customer ID ‘{managerCustomerId}‘”);
} catch (GoogleAdsException e) {
Console.WriteLine($”Error: {e.Message}, Request ID: {e.RequestId}“);
throw;
}
}

PHP

public static function runExample(GoogleAdsClient $googleAdsClient, int $managerCustomerId) {
$customer = new Customer([
'descriptive_name' => 'Account created with CustomerService on ' . date('Ymd h:i:s'),
'currency_code' => 'USD',
'time_zone' => 'America/New_York',
'tracking_url_template' => '{lpurl}?device={device}',
'final_url_suffix' => 'keyword={keyword}&matchtype={matchtype}&adgroupid={adgroupid}'
]);
$customerServiceClient = $googleAdsClient->getCustomerServiceClient();
$response = $customerServiceClient->createCustomerClient(CreateCustomerClientRequest::build($managerCustomerId, $customer));

printf(“Created a customer with resource name ‘%s’ under the manager account with customer ID %d.%s”,
$response->getResourceName(), $managerCustomerId, PHP_EOL);
}

Python

def main(client, manager_customer_id):
customer_service = client.get_service("CustomerService")
customer = client.get_type("Customer")
now = datetime.today().strftime("%Y%m%d %H:%M:%S")
customer.descriptive_name = f"Account created with CustomerService on {now}"
customer.currency_code = "USD"
customer.time_zone = "America/New_York"
customer.tracking_url_template = "{lpurl}?device={device}"
customer.final_url_suffix = "keyword={keyword}&matchtype={matchtype}&adgroupid={adgroupid}"
response = customer_service.create_customer_client(customer_id=manager_customer_id, customer_client=customer)
print(f’Customer created with resource name “{response.resource_name}” under manager account with ID “{manager_customer_id}“.’)

Ruby

def create_customer(manager_customer_id)
client = Google::Ads::GoogleAds::GoogleAdsClient.new
customer = client.resource.customer do |c|
c.descriptive_name = “Account created with CustomerService on #{(Time.new.to_f * 1000).to_i}“
c.currency_code = “USD”
c.time_zone = “America/New_York”
c.tracking_url_template = “{lpurl}?device={device}”
c.final_url_suffix = “keyword={keyword}&matchtype={matchtype}&adgroupid={adgroupid}”
end

response = client.service.customer.create_customer_client(customer_id: manager_customer_id, customer_client: customer)
puts “Created a customer with resource name #{response.resource_name} under the manager account with customer ID #{manager_customer_id}.”
end

Perl
sub create_customer {
my ($api_client, $manager_customer_id) = @_;
# Khởi tạo một đối tượng khách hàng để tạo mới.
my $customer = Google::Ads::GoogleAds::V17::Resources::Customer->new({
descriptiveName => “Tài khoản được tạo bằng CustomerService vào #” . uniqid(),

# Để biết danh sách mã tiền tệ và múi giờ hợp lệ, xem tài liệu tại:
# https://developers.google.com/google-ads/api/reference/data/codes-formats
currencyCode => “USD”,
timeZone => “America/New_York”,

# Các giá trị dưới đây là tuỳ chọn. Để biết thêm về các tuỳ chọn URL, xem:
# https://support.google.com/google-ads/answer/6305348
trackingUrlTemplate => “{lpurl}?device={device}”,
finalUrlSuffix => “keyword={keyword}&matchtype={matchtype}&adgroupid={adgroupid}”
});

# Tạo khách hàng mới.
my $create_customer_client_response =
$api_client->CustomerService()->create_customer_client({
customerId => $manager_customer_id,
customerClient => $customer
});

printf
“Đã tạo một khách hàng với tên tài nguyên ‘%s’ dưới tài khoản quản lý “ .
“có mã khách hàng %d.\n”, $create_customer_client_response->{resourceName},
$manager_customer_id;

return 1;
}

Việc quản lý tài khoản quảng cáo trên Google Ads chưa bao giờ đơn giản và hiệu quả như khi sử dụng Google Ads API. Từ việc tạo tài khoản mới cho đến quản lý hệ thống phân cấp tài khoản, API mang đến cho bạn công cụ mạnh mẽ để quản lý chiến dịch quảng cáo chuyên nghiệp. Hãy tận dụng tối đa các khả năng mà Google Ads API cung cấp để cải thiện hiệu suất chiến dịch và tăng cường trải nghiệm quảng cáo cho doanh nghiệp của bạn. Bắt đầu khám phá Google Ads API ngay hôm nay để đơn giản hóa quy trình quản lý và tăng cường hiệu quả quảng cáo!

Mục lục

Tư vấn dịch vụ Website miễn phí

Nhận báo giá dịch vụ Website

Gửi V4SEO đường dẫn website và mục tiêu của bạn. Chúng tôi xem thực trạng rồi báo lại phạm vi công việc và con số cụ thể — không phải mức tham khảo.

  • Báo giá theo đúng phạm vi đã chốt, không phát sinh ngoài thỏa thuận
  • Chỉ ra trước những điểm cần sửa, kể cả khi bạn chưa dùng dịch vụ
  • Tư vấn 24/7 qua kênh bạn tiện nhất
088 880 3635Gọi trực tiếp, nhanh nhất