This post explains how to automatically add a customer account to an MCC account using the AdWords API. After five years of being asked the same question, I can finally answer “yes!”, when people ask me if it’s possible to create accounts via the AdWords API. The new CreateAccountService was announced last week, which is great news for AdWords API developers.
How It Works
The API announcement follows on from an earlier one about a feature that allows accounts to be created within an MCC account without needing to have an associated Google login. You can now go into an MCC account and simply press the “Create Account” button, then it will be added to your list of managed accounts:
You need to specify the country, timezone, and currency at this point, and you can also invite a user—for example your client—to access the account with a normal Google login. However, it’s not possible to add a payment method from this screen, so you need to either use Manager Defined Spend or manually go into the account and set it.
How To Use the ManagedCustomerService
It’s actually pretty simple to create a new account as it just follows the same format as most AdWords API operations. Here’s an example using the PHP client library:
<?php require_once 'Google/Api/Ads/AdWords/Lib/AdWordsUser.php'; $username = "email@example.com"; $password = "pa55word"; $developerToken = "your_dev_token"; $user = new AdWordsUser(null, $username, $password, $developerToken); $managedCustomerService = $user->GetService("ManagedCustomerService", "v201209"); $customer = new ManagedCustomer(); $customer->name = "Test Account"; $customer->currencyCode = "USD"; $customer->dateTimeZone = 'Europe/London'; $operation = new ManagedCustomerOperation(); $operation->operator = 'ADD'; $operation->operand = $customer; $operations = array($operation); $accounts = $managedCustomerService->mutate($operations); print_r($accounts); ?>
That’s pretty much it. There are just a few items of note here:
- Accounts are actually called “Customers”, so you create
ManagedCustomerobjects and send them to the
- You need to construct an
ManagedCustomerobject for each account you want to create; these require a name, currency code, and timezone.
- As with most mutate operations, you can create multiple accounts at the same time by using multiple operations.
This is definitely going to be a useful addition to the AdWords API, and I’m sure I’ll be using it in a project soon. It would also be nice to have the ability to invite a user once the account was created, but apart from that it should be perfect for agencies; especially ones using MDS who won’t need to worry about adding credit card details.