Linking account with Manager Account in Google Ads API

373 views
Skip to first unread message

Amrender kumar

unread,
May 22, 2019, 10:06:31 AM5/22/19
to AdWords API and Google Ads API Forum
Hi there!
Can someone please advise how to convert the example of Linking customer account with Manager account in Google Ads API? I was going through the Ads documentation and I came to the example here https://developers.google.com/google-ads/api/docs/account-management/linking-manager-accounts 
However, it is done in Ruby language only. Can you please convert it into PHP so that I can use it in my YII2 application.

Thanks,
Amrender

Google Ads API Forum Advisor Prod

unread,
May 22, 2019, 5:15:48 PM5/22/19
to adwor...@googlegroups.com
Hello Amerender,

As of now the examples in other languages is not available, they will be available soon. Meanwhile you could try the same pattern by following the available example in PHP.

Regards,
Sai Teja, Google Ads API Team

ref:_00D1U1174p._5001UAqLBq:ref

Amrender kumar

unread,
Jun 10, 2019, 8:30:15 AM6/10/19
to AdWords API and Google Ads API Forum
Hi Support team,
I was trying to write code to link customer account with manager account in PHP however I am facing issues with it.
I have written piece of code:
$customerManagerLink = new CustomerManagerLink();
$customerManagerLink->setManagerCustomer(new StringValue(['value' => self::MANAGER_CUSTOMER_ID]));
$customerManagerLink->setManagerLinkId(new Int64Value(['value' => $CLIENT_CUSTOMER_ID]));

$customerManagerLink->setStatus(new EnumValue(['number' => 0]));



In the last line, to set status, in documentation it says it accepts enum however when I am passing Enum value, it is throwing error/exception as " Expect integer."

I also tried as $customerManagerLink->setStatus('PENDING'); OR  $customerManagerLink->setStatus(new EnumValue(['name' => PENDING]));  OR 
$customerManagerLink->setStatus(new EnumValue(['name' => 'PENDING']));

I also tried by passing Integer values however it still throws the same error.

Is there any issue with the library functions? Please guide me here as I am stuck completely. 

Thanks!

Google Ads API Forum Advisor Prod

unread,
Jun 10, 2019, 1:03:57 PM6/10/19
to adwor...@googlegroups.com
Hello Amerender,

I replied to your email address directly on May 28th. However here is the response I sent "The code sample in PHP is available here . You could use LinkManagerToClient.php  example. "

If you want o expand the invitation from the manager account you have to use customerClientLink and then set status as shown here, then to accept the invitation you have to use CustomerManagerLinkService. Refer here for more information.

Amrender kumar

unread,
Jun 11, 2019, 9:59:44 AM6/11/19
to adsapifor...@gmail.com, adwor...@googlegroups.com
Hi Teja,
Thanks for your message.

I tried to run the example you shared however I am getting error "Invalid_Grant" in Oauth2 flow. Please find the attached sshot. Is there anything I need to enable at Ads API end or any other issue is there? Please help me. I am trying to link account with manger id 9663159860 . 

I look forward to hearing from you soon.

Thanks,
Amrender



--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads 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
---
You received this message because you are subscribed to a topic in the Google Groups "AdWords API and Google Ads API Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adwords-api/oNMMozQ9b6o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-api...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/idkaf000000000000000000000000000000000000000000000PSW7E4001lrz8YmmSOyC0nQVmoZ2OA%40sfdc.net.


--
Kind Regards,
Amrender Kumar

ads_error.png

Amrender kumar

unread,
Jun 27, 2019, 3:22:13 AM6/27/19
to AdWords API and Google Ads API Forum
Hi Teja/Google Ads Team,
Could you please help me here as I am totally stuck at this point.

To make sure I am not making any mistake, I created a separate setup (https://www.clickenforcer.com/googleads)  to link my manager account (9663159860) with other Ads account. The request is being set successfully to link the account however while approving it (https://github.com/googleads/google-ads-php/blob/master/examples/AccountManagement/LinkManagerToClient.php#L247) , it is throwing error as mentioned below:

Fatal error: Uncaught Google\ApiCore\ApiException: { "message": "The caller does not have permission", "code": 7, "status": "PERMISSION_DENIED", "details": [ { "@type": "google.ads.googleads.v1.errors.googleadsfailure-bin", "data": "<Unknown Binary Data>" }, { "@type": "grpc-status-details-bin", "data": "<Unknown Binary Data>" }, { "@type": "request-id", "data": "zQhBL1aserIITJYgoDP6vQ" } ] } thrown in /home/clickenforcer/public_html/googleads/google-ads-php/src/Google/Ads/GoogleAds/Lib/V1/GoogleAdsExceptionMiddleware.php on line 106

I am following the example present on your git repo (https://github.com/googleads/google-ads-php/blob/master/examples/AccountManagement/LinkManagerToClient.php) and created the flow here:


Could you please help me here what is wrong in the code which is not allowing to run it properly? Is there anything wrong in the example you guys have posted on GIT repo? 
I am totally stuck at this point. Please let me know if you need any other information from my end.

I look forward to your prompt response in this.

Thanks,
Amrender


On Tuesday, 11 June 2019 19:29:44 UTC+5:30, Amrender kumar wrote:
Hi Teja,
Thanks for your message.

I tried to run the example you shared however I am getting error "Invalid_Grant" in Oauth2 flow. Please find the attached sshot. Is there anything I need to enable at Ads API end or any other issue is there? Please help me. I am trying to link account with manger id 9663159860 . 

I look forward to hearing from you soon.

Thanks,
Amrender



On Mon, 10 Jun 2019 at 22:33, Google Ads API Forum Advisor Prod <adsapifor...@gmail.com> wrote:
Hello Amerender,

I replied to your email address directly on May 28th. However here is the response I sent "The code sample in PHP is available here . You could use LinkManagerToClient.php  example. "

If you want o expand the invitation from the manager account you have to use customerClientLink and then set status as shown here, then to accept the invitation you have to use CustomerManagerLinkService. Refer here for more information.

Regards,
Sai Teja, Google Ads API Team

ref:_00D1U1174p._5001UAqLBq:ref

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "AdWords API and Google Ads API Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adwords-api/oNMMozQ9b6o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-api+unsubscribe@googlegroups.com.

Google Ads API Forum Advisor Prod

unread,
Jun 27, 2019, 12:41:37 PM6/27/19
to adwor...@googlegroups.com
Hello Amrender,

Could you please confirm whether you are using the credentials of the client that is expected to accept the invitation while running accept_invitation method?

In general when a manager account invites clients to link the request is made from the manager account so the OAuth credentials is of that manager. When accepting the invitation the client account should accept the invitation so the OAuth credentials should be of the user having access to the client account.

If you are still facing the error please share the email address and the client customer id to investigate further.

Amrender kumar

unread,
Jun 27, 2019, 1:26:12 PM6/27/19
to adsapifor...@gmail.com, adwor...@googlegroups.com
Hi Teja,
Thanks for your prompt reply.

I would like to mention that in the example provided, it does pass the clientCustomerId in the process of accepting the invitation. You can refer here https://github.com/googleads/google-ads-php/blob/master/examples/AccountManagement/LinkManagerToClient.php#L230

I am following the same code and it should work fine if your example is written correctly.

I tried with few email address without any luck. I tried with amrender....@gmail.com , mitizt...@gmail.com . Kindly review and let me know if you need any further information.

Thanks,
Amrender

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "AdWords API and Google Ads API Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adwords-api/oNMMozQ9b6o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-api...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/fi2oA000000000000000000000000000000000000000000000PTRNOX00ayWifSZvSPyyB32YryVVjg%40sfdc.net.

Amrender kumar

unread,
Jul 2, 2019, 2:51:17 AM7/2/19
to adsapifor...@gmail.com, adwor...@googlegroups.com
Hi Teja,
Hope you are well.

I did not hear anything from your end? Could you please respond to my queries at your earliest convenience as I am stuck with this linking feature?

I look forward to hearing from you.

Thanks,
Amrender

Google Ads API Forum Advisor Prod

unread,
Jul 2, 2019, 4:47:24 PM7/2/19
to adwor...@googlegroups.com
Hello Amrender,

Seems like my earliest response didn't reach to you. Could you please share the exact client customer id that our are passing tho the accept invitation method to help further? Please use reply privately to the author option while sharing the information requested. 

Amrender kumar

unread,
Jul 2, 2019, 11:50:34 PM7/2/19
to adsapifor...@gmail.com, adwor...@googlegroups.com
Hi Teja,
I did reply to your email. Here is the content again:

I would like to mention that in the example provided, it does pass the clientCustomerId in the process of accepting the invitation. You can refer here https://github.com/googleads/google-ads-php/blob/master/examples/AccountManagement/LinkManagerToClient.php#L230

I am following the same code and it should work fine if your example is written correctly.

I tried with few email address without any luck. I tried with amrender....@gmail.com , mitizt...@gmail.com . Kindly review and let me know if you need any further information.

Thanks,
Amrender
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads 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
---
You received this message because you are subscribed to a topic in the Google Groups "AdWords API and Google Ads API Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adwords-api/oNMMozQ9b6o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-api...@googlegroups.com.

Google Ads API Forum Advisor Prod

unread,
Jul 3, 2019, 8:02:01 AM7/3/19
to adwor...@googlegroups.com
Hello Amrender,

Could you please share the Customer iD(looks like 123-456-7890) to check if the email addresses provided has access to that account in order to accept the link?

Amrender kumar

unread,
Jul 3, 2019, 8:12:41 AM7/3/19
to adsapifor...@gmail.com, adwor...@googlegroups.com
Hi Teja,
The manager id is 966-315-9860 and customer id I am trying with are 524-213-6927669-437-8287
Please let me know in case of any other information needed.

Thanks,
Amrender

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads 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
---
You received this message because you are subscribed to a topic in the Google Groups "AdWords API and Google Ads API Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adwords-api/oNMMozQ9b6o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-api...@googlegroups.com.

Google Ads API Forum Advisor Prod

unread,
Jul 3, 2019, 10:56:31 AM7/3/19
to adwor...@googlegroups.com
Hello Amerender,

Thanks for sharing the ids. I was able to confirm that the emails shared has access to the client accounts shared. Since we are seeing Permission denied error the reason could be one of the 2 mentioned below.
  1. Even though the OAuth credentials are from the respective users having access to those client accounts, If you are setting an MCC ID that is not yet the manager of these accounts as login-customer-id in your API call you may see this error. To avoid this you have to set the login-customer-id as the same client id or blank while accepting the invitation.
  2. If it is not the above reason then you may try creating new set of OAuth credentials and make sure the API call is made with those credentials while making accepting invitation call.
Please note that each email address has access to one account only so if you are creating fresh OAuth have to create a set for each email address.

Amrender kumar

unread,
Jul 4, 2019, 10:00:50 AM7/4/19
to adsapifor...@gmail.com, adwor...@googlegroups.com
Hi Teja,
Thank you for your response.

I would like to mention that none of your suggested approach worked for me. I am still seeing same error. 
Is the example Ads team has provided over GIT working properly or it's tested?  Please let me know how can I proceed further. 

Thanks,
Amrender

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads 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
---
You received this message because you are subscribed to a topic in the Google Groups "AdWords API and Google Ads API Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adwords-api/oNMMozQ9b6o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-api...@googlegroups.com.

Google Ads API Forum Advisor Prod

unread,
Jul 8, 2019, 10:39:38 AM7/8/19
to adwor...@googlegroups.com
Hello Amrender,

To analyze further, could you please share the complete request and response log containing request id? Also please specify or share the guide that you followed to create OAuth credentials. You could use reply privately to the author option while sharing the information requested.  

Amrender kumar

unread,
Jul 10, 2019, 8:39:35 AM7/10/19
to AdWords API and Google Ads API Forum
Hi Teja,
I have managed to fix the problem. It seems working now.

Thank you for your help.

Thanks,
Amrender

Amrender kumar

unread,
Jul 11, 2019, 8:49:36 AM7/11/19
to AdWords API and Google Ads API Forum
Hi Teja,
I am trying to implement block ip functionality using Ads API however I could not find the steps of the code that needs to be written. I am trying to follow this example (https://github.com/googleads/google-ads-php/blob/master/examples/Targeting/AddCampaignTargetingCriteria.php) however I am unable to make it work. Could you please guide me here and let me know the steps so that I can write the code to do it? I have written following code and I am not sure if I am on the right track:

$campaignResourceName = ResourceNames::forCampaign($adwords_user_id, $adwords_campaign_id); 
$ipBlock = new IpBlockInfo();
$ipBlock->setIpAddress($ipAddress);

$campaignCriterion = new CampaignCriterion([
// Creates a keyword with BROAD match type.
'keyword' => new KeywordInfo([
'text' => new StringValue(['value' => $adwords_campaign_name]),
'match_type' => KeywordMatchType::BROAD
]),
// Sets the campaign criterion as a negative criterion.
'negative' => new BoolValue(['value' => true]),
'campaign' => new StringValue(['value' => $campaignResourceName])
]); 

$operation = new CampaignCriterionOperation();
$operation->setOperator('ADD');
$operation->setOperand($campaignCriterion);
$operations[] = $operation;

$campaignCriterionServiceClient = $googleAdsClient->getCampaignCriterionServiceClient();
$response =$campaignCriterionServiceClient->mutateCampaignCriteria($adwords_user_id, $operations);
            

I look forward to hear from you soon.

Thanks,
Amrender 

On Monday, 8 July 2019 20:09:38 UTC+5:30, adsapiforumadvisor wrote:

Google Ads API Forum Advisor Prod

unread,
Jul 11, 2019, 1:59:09 PM7/11/19
to amrender....@gmail.com, adwor...@googlegroups.com
Hello Amrender,

If you want to use the IP block at campaign level you have to use IpBlockInfo inside the CampaignCriterion instead and keep the CriterionType as IP_BLOCK. If you want to keep the keyword targeting then you have to create another CampaignCriterionOperation and then ass IpBlock campaignCriterion to it then add it to the operations in order to pass the IPBlock to the mutate request. Please let me know if you have any further questions.

Amrender kumar

unread,
Jul 22, 2019, 7:25:14 AM7/22/19
to adsapifor...@gmail.com, adwor...@googlegroups.com
Hi Teja,
Thanks for your help. I did implemented the block API successfully as per your suggestions.

Further, I was trying to implement Keyword Planning API to fetch keywords stats or search volume. I am following this example:
https://github.com/googleads/google-ads-php/blob/master/examples/Planning/GenerateKeywordIdeas.php

I came to know that the API needs a location id that can be grabbed from the CSV present here (https://developers.google.com/adwords/api/docs/appendix/geotargeting). My questions here are:
- Do we need to show this list to my end users (in any selectbox or auto suggested box) on my website in order to choose the desired location? Or is there any alternative solution / API that we can use to generate this location id to use in the API?
- If we insert this CSV into our database with same structure, do we need to update it regularly when it is changed from Ads team?
- Does this list include all the cities of world so that users can choose their desired city?

Kindly reply my queries above so that I can integrate the API accordingly.


I look forward to hear from you soon.

Thanks,
Amrender
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads 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
---
You received this message because you are subscribed to a topic in the Google Groups "AdWords API and Google Ads API Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adwords-api/oNMMozQ9b6o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-api...@googlegroups.com.

Google Ads API Forum Advisor Prod

unread,
Jul 22, 2019, 2:48:20 PM7/22/19
to adwor...@googlegroups.com
Hello Amerender,

As an alternative you could use the geo_target_constant resource Which will return those location criterion that are shown in the table, so that you don't have to worry about storing them and updating the table later. You can also use the part of the location name to get all the matched locations as shown below. Please give it a try and let me know if you have any further questions.

Sample Query:
"SELECT geo_target_constant.canonical_name, geo_target_constant.country_code, geo_target_constant.id, geo_target_constant.name FROM geo_target_constant WHERE geo_target_constant.name LIKE 'New york' "
Reply all
Reply to author
Forward
0 new messages