best method for getting customerId in v201109?

516 views
Skip to first unread message

sms_adwords

unread,
Jan 17, 2012, 2:36:55 PM1/17/12
to adwor...@googlegroups.com
Hello AdWords folks,

Just as the topic says, I'm trying to migrate from v13/v201101 to v201109 and am curious about the suggested method for getting customerId in a non-mcc account. If I use the method suggested here http://code.google.com/p/google-api-ads-python/source/browse/trunk/examples/adspygoogle/adwords/v201109/account_management/get_account_hierarchy.py I get a customerId of 0.

My only modification to the example was commenting out the print and adding a simpler one:
#print '%s%s%s, %s%s' % (prefix, account['login'], descriptive_name,
#                        account['customerId'], link_text)
print account

Here are my (sanitized) logs/output:

$ python get_account_hierarchy.py
[2012-01-17 14:16:21,506::DEBUG::AwApi-Python-15.1.4] StartTime: 2012-01-17 14:1
6:21
*** Outgoing HTTP headers **********************************************
POST /api/adwords/mcm/v201109/ServicedAccountService HTTP/1.0
Host:adwords.google.com
User-agent:SOAPpy 0.12.0 (pywebsvcs.sf.net),gzip
XML-parser: xml.etree.cElementTree v1.0.6
Content-type:text/xml; charset="UTF-8"
Content-length:694
Accept-Encoding:gzip
Content-Encoding:gzip
SOAPAction:"get"
************************************************************************
*** Outgoing SOAP ******************************************************
<?xml version='1.0' encoding='UTF-8'?>
<ns0:Envelope ns0:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmln
s:ns0="http://schemas.xmlsoap.org/soap/envelope/">
 <ns0:Header>
  <ns1:RequestHeader xmlns:ns1="https://adwords.google.com/api/adwords/mcm/v2011
09">
   <ns2:developerToken xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201
109">XXXXXXXXXXXXXXXXXXXXXXXXXX</ns2:developerToken>
   <ns2:userAgent xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201109">
AwApi-Python-15.1.4|Test Client</ns2:userAgent>
   <ns2:authToken xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201109">
X</ns2:authToken>
  </ns1:RequestHeader>
 </ns0:Header>
 <ns0:Body>
  <ns1:get xmlns:ns1="https://adwords.google.com/api/adwords/mcm/v201109">
   <ns1:selector ns2:type="mcm:ServicedAccountSelector" xmlns:ns2="http://www.w3
.org/2001/XMLSchema-instance">
    <ns1:enablePaging>false</ns1:enablePaging>
   </ns1:selector>
  </ns1:get>
 </ns0:Body>
</ns0:Envelope>
************************************************************************
*** Incoming HTTP headers **********************************************
HTTP/1.? 200 OK
Content-Type: text/xml; charset=UTF-8
Content-Encoding: gzip
Date: Tue, 17 Jan 2012 19:16:21 GMT
Expires: Tue, 17 Jan 2012 19:16:21 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Content-Length: 337
Server: GSE
************************************************************************
*** Incoming SOAP ******************************************************
<?xml version='1.0' encoding='UTF-8'?>
<ns0:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/">
 <ns0:Header>
  <ns1:ResponseHeader xmlns:ns1="https://adwords.google.com/api/adwords/mcm/v201
109">
   <ns2:requestId xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201109">
0004b6be2a9536900aecc56700001ab6</ns2:requestId>
   <ns2:serviceName xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201109
">ServicedAccountService</ns2:serviceName>
   <ns2:methodName xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201109"
>get</ns2:methodName>
   <ns2:operations xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201109"
>0</ns2:operations>
   <ns2:responseTime xmlns:ns2="https://adwords.google.com/api/adwords/cm/v20110
9">49</ns2:responseTime>
   <ns2:units xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201109">0</n
s2:units>
  </ns1:ResponseHeader>
 </ns0:Header>
 <ns0:Body>
  <ns1:getResponse xmlns:ns1="https://adwords.google.com/api/adwords/mcm/v201109
">
   <ns1:rval>
    <ns1:accounts>
     <ns1:customerId>0</ns1:customerId>
     <ns1:canManageClients>false</ns1:canManageClients>
    </ns1:accounts>
   </ns1:rval>
  </ns1:getResponse>
 </ns0:Body>
</ns0:Envelope>
************************************************************************
EndTime: 2012-01-17 14:16:21
[2012-01-17 14:16:21,618::DEBUG::AwApi-Python-15.1.4] host=adwords.google.com se
rvice=ServicedAccountService method=get operator=None responseTime=49 operations
=0 units=0 requestId=0004b6be2a9536900aecc56700001ab6 isFault=False
Login, CustomerId (Status)
{'canManageClients': 'false', 'customerId': '0'}

Usage: 0 units, 0 operations

David Bonner

unread,
Jan 17, 2012, 3:39:14 PM1/17/12
to adwor...@googlegroups.com
It's a known bug in the sandbox server, it always returns a customerId of 0 for the mcc account.

yagmur

unread,
Jan 17, 2012, 4:09:15 PM1/17/12
to adwor...@googlegroups.com
David, it's actually not only the sandbox. I've been waiting for the fix for a few weeks now...

For now, you might have to ask your customers for their customer number, of course you can limit that to customers who are not part of an mcc... figuring that out is another story too :) This is an annoying bug...

Refer to this thread for more...

Kevin Winter

unread,
Jan 23, 2012, 10:36:36 AM1/23/12
to adwor...@googlegroups.com
Hi,
  Unfortunately, due to the implementation of the ServicedAccountService, it has issues returning the data you would expect with accounts that have no links.  Our current (admittedly hacky) solution it to suggest using an AdHoc report to obtain an AccountPerformanceReport and request the AccountId.  If you have no impressions, you'll need to use a Campaign Performance report (assuming at least one campaign).

- Kevin Winter
AdWords API Team

sms_adwords

unread,
Jan 23, 2012, 11:44:07 AM1/23/12
to adwor...@googlegroups.com
Hi Kevin,

Thanks for the response. It's my understanding that currently the API requires a clientCustomerId to download reports. Is there a different method (not involving downloading reports) to acquire the Id?

Thanks,
Sean

yagmur

unread,
Jan 23, 2012, 12:20:56 PM1/23/12
to AdWords API Forum
Sean that is my understanding too! That's why it is so contradictory
to require a piece of data that is not available to start with.

Kevin are you saying there is a hack? Please share the details, this
is taking a toll on our business!

Best,
Yagmur

Kevin Winter

unread,
Jan 23, 2012, 2:10:54 PM1/23/12
to adwor...@googlegroups.com
Hi Sean,
  I apologize, I presented an invalid solution earlier.  The Account/Campaign report workaround is our recommendation for obtaining the currency code and timezone (which are the other two most commonly requested fields from the v13 AccountService).

For unlinked accounts, we do not currently have a good method to obtain clientCustomerId - but we're currently looking into options to alleviate this shortcoming.

- Kevin Winter
AdWords API Team

yagmur

unread,
Jan 26, 2012, 2:46:33 PM1/26/12
to AdWords API Forum
Per this issue, customer id being returned was -1 but now it is 0
instead. Just an fyi to all who are doing something like:

...
ServicedAccountGraph graph = servicedAccountService.get(selector);
if (graph.accounts[0].customerId == -1) {
// handle non-mcc account
}

You might have to change it to:

...
ServicedAccountGraph graph = servicedAccountService.get(selector);
if (graph.accounts[0].customerId == -1 || graph.accounts[0].customerId
== 0) {
// handle non-mcc account
}

Best,
Yagmur

chris h

unread,
Feb 22, 2012, 2:59:18 AM2/22/12
to AdWords API Forum
Hi Kevin,

I figured I'd check in on this before the Hangout tomorrow since I'll
bring this up to find out if there is any update.

Thanks,
Chris


On Jan 23, 2:10 pm, Kevin Winter <Kevin.Win...@google.com> wrote:

Kevin Winter

unread,
Feb 22, 2012, 7:43:45 AM2/22/12
to adwor...@googlegroups.com
Hi Chris,
  No update yet, but we hope to have something for you soon.

- Kevin Winter
AdWords API Team

Kevin Winter

unread,
Feb 22, 2012, 5:05:15 PM2/22/12
to adwor...@googlegroups.com
Hi Chris,
  We just verified that we pushed a change to production such that if you make an InfoService request authenticated with an account not linked to your MCC/developer token, it will still return a record for that clientCustomerId.  I.E., authenticate with ANY account and the InfoService will return a record for this account.  Previously, this service only worked when authenticating as an MCC.

- Kevin Winter
AdWords API Team

Yagmur Coker

unread,
Feb 22, 2012, 5:33:12 PM2/22/12
to Kevin....@google.com, adwor...@googlegroups.com
Awesome news!

--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en

chris h

unread,
Feb 23, 2012, 11:44:15 AM2/23/12
to adwor...@googlegroups.com
Hi Kevin,
Should this work with an existing oauth token? Or do I need to get a new token? I'm sure my token was created before you made this change.

Kevin Winter

unread,
Feb 23, 2012, 11:52:09 AM2/23/12
to adwor...@googlegroups.com
Hi Chris,
  Yes, that should work.  It bases this behavior on the authenticated user (which needs to be a non-MCC account).

- Kevin Winter
AdWords API Team

Ben Vincent

unread,
May 8, 2012, 12:26:53 PM5/8/12
to adwor...@googlegroups.com
Hi Kevin,
 
Are there still issues with the CustomerID = 0?
 
For most my clients, I have no problems and can look up the Customer ID. But sometimes it comes back as 0.
 
For example I just got this response:
 
<soap:Header>
<ns2:requestId>0004bf88a41487c80aec782b00003b94</ns2:requestId>
<ns2:serviceName>ServicedAccountService</ns2:serviceName>
<ns2:methodName>get</ns2:methodName>
<ns2:operations>0</ns2:operations>
<ns2:responseTime>25</ns2:responseTime>
<ns2:units>0</ns2:units>
</ResponseHeader>
</soap:Header>
<soap:Body>
<accounts><customerId>0</customerId><canManageClients>false</canManageClients></accounts>
</rval>
</getResponse>
</soap:Body>
</soap:Envelope>
 
 
I am trying to run AdHoc reports for clients, for which I need the customerID. My code checks to see if I have the customer ID in my local DB, and if not it looks it up. Usually this works, but occasionally it fails. If I then look up the ID manually by logging into the web interface and copying the CustomerID, AdHoc reports work fine.
 
Any ideas why?
 
Thanks
 
Ben

Kevin Winter

unread,
May 15, 2012, 10:12:51 AM5/15/12
to adwor...@googlegroups.com
Hi Ben (and future forum viewers),
  We discussed this offline.  Because this is an unlinked account (no parent MCC) the ServicedAccountService can't operate on it (it can only "see" accounts with parents).  As a workaround, making an InfoService request for this account (as I mentioned in my message on 2/22) will work.

- Kevin Winter
AdWords API Team

Rob

unread,
Aug 15, 2012, 7:28:47 AM8/15/12
to adwor...@googlegroups.com
Hi Kevin,

I've just started using the v201206 ManagedCustomerService and it appears to work even for non-MCC logins, showing the customer ID as well as the time zone and currency code.

Can you please confirm this is expected behaviour and that we can use the new service to get information for all accounts?

Kevin Winter

unread,
Aug 15, 2012, 9:52:28 AM8/15/12
to adwor...@googlegroups.com
Hi,
  Technically, the ManagedCustomerService will return results for any AdWords account that matches the selector (i.e. the authenticated account) as long as it is managed by an MCC account.  This limitation will prevent the MCS from returning results for client accounts (even when authenticated) if this account is not managed by any MCC.  For this reason, we recommend using the CustomerService if you are authenticating directly with a client account (which will always return results) or if you know the clientCustomerId and just want to get account information.

- Kevin Winter
AdWords API Team

Rob

unread,
Aug 15, 2012, 10:11:56 AM8/15/12
to adwor...@googlegroups.com
Hi Kevin, and thanks for the reply.

That makes sense, so I'll stick to polling both the CustomerService and the ManagedCustomerService.  It's a shame there isn't one service that will provide this information reliably for all logins. The new Customer services are definitely an improvement over the old Account services but they still fall a little short :(
Reply all
Reply to author
Forward
0 new messages