sending offline conversions for multiple accounts using python

84 views
Skip to first unread message

BIP

unread,
Mar 21, 2018, 5:13:28 PM3/21/18
to AdWords API Forum
Hi,

We're using the same developer token and refresh token for multiple services in the company. This time, we're sending offline conversions (client.GetService('OfflineConversionFeedService', version='v201802')) to multiple accounts under the same MCC account. 
So, running some tests, we were able to successfully upload conversions to a specific account using authentication with yaml file:
adwords_client = adwords.AdWordsClient.LoadFromStorage()

However, since our daily operations will include sending conversions to several accounts, we wouldn't like to have to hold many yaml files...

Going over the forum, we found a workaround (https://groups.google.com/forum/#!msg/adwords-api/ksKHY7xUxiQ/M80f-uHQKQAJ) - that suggests to not use the LoadFromStorage(), but rather use:
adwords_client = adwords.AdWordsClient( developer_token, oauth2_client, user_agent, client_customer_id)

I'm not sure if this solution fits our offline needs, which is basically to avoid generate a new refresh_token/access_token each time we attempt to authenticate. We can't refresh the refresh_token, since other internal applications are using this same refresh_token.

I've looked everywhere in the forum and documentation and wasn't able to find a suitable answer to this situation. 

Questions:
1. Is my assumption that the oauth2_client refreshes the refresh_token correct? 
2. Can we use adwords.AdWordsClient without having the refresh anything? just pass it any of the following?: developer_token, client_customer_id, client_id, client_secret, refresh_token
3. Can you suggest an alternative solution? so we don't have to use multiple yaml files, or refresh the refresh_token.. And of course, that we can implement using Python.


Thanks in advance!
Liron

Peter Oliquino

unread,
Mar 22, 2018, 1:12:05 AM3/22/18
to AdWords API Forum
Hi Liron,

In order to avoid using multiple OAuth2 credentials and yaml files for each of those client accounts under your MCC, I would recommend that you generate new OAuth2 credentials using an email address that has access to your MCC account. This way, the generated OAuth2 credentials would have access to all the client accounts under the said MCC's hierarchy. Afterwards, you may then refer to the Parallel Report Download example and see how you can iterate through the client accounts of your MCC then trigger a request for uploading conversions.
This said, this should address your number 3 question.

As for your number 1 and 2 questions, by using the supported client libraries of the AdWords API, it will automatically refresh your access tokens and you will no longer have a need to manually trigger the refresh. I hope this helps and feel free to write back if you have any further clarifications.

Best regards,
Peter
AdWords API Team

BIP

unread,
Mar 22, 2018, 5:43:50 AM3/22/18
to AdWords API Forum
Hi Peter,
Thank you for the response! 
I still do not understand a few things:

1. In the Parallel Report Download example you provided, the authentication in still being done using a yaml file. Doesn't it require a customer ID? I don't understand how you can authenticate via a yaml file and then provided different customer IDs.. does it override the original customer ID set in the yaml file?

2. "automatically refresh your access tokens" - means that it will generate a new refresh token? We're using a hard coded refresh token in the yaml file and don't want it to change...

3. https://developers.google.com/adwords/api/docs/guides/conversion-tracking#importing_click_conversions - Found this:
"When uploading click conversions for multiple accounts, you can specify the clientCustomerId of a common manager account and include operations with GCLIDs from across multiple accounts. A conversion is attributed to the proper account based on the origin of its GCLID."
Can this apply for my needs? Can I set the customer ID in the yaml file to be the MCC one and send gclids of it's child accounts and it will find the match?

Thanks,
Liron

Peter Oliquino

unread,
Mar 22, 2018, 11:36:02 PM3/22/18
to AdWords API Forum
Hi Liron,

You may refer below for my answers to your questions :

1. The clientCustomerId that you would specify during this should be the account ID of your MCC account. As for the example itself, it will retrieve all the client accounts of the said MCC using the ManagedCustomerService.get() method and then use the client account's ID when passing the request.

2. The refreshToken that you specify in the yaml file will not be changed. The client library will then automatically use that refreshToken to regenerate access tokens (which expire after sometime) without you having to generate the access tokens yourselves.

3. This approach would also be possible. However, before you can do so, the ConversionTracker should be first created at the MCC level. This way, you will be able to upload the conversions to that MCC if those said conversions were recorded by the MCC level ConversionTracker. You may also note that conversions uploaded to the MCC would not be directly attributed to the MCC, you will still need to look for them at the specific campaign of the client account of the said MCC.
Reply all
Reply to author
Forward
0 new messages