Google ads customer list using PHP REST API

79 views
Skip to first unread message

Amit

unread,
May 4, 2020, 1:17:39 PM5/4/20
to AdWords API and Google Ads API Forum
Hi. 

How do I retrieve customer list after OAuth2.0 login authentication using REST API PHP? 

I am looking for the customer IDs and Names after successful login. I wish to retrieve the result in JSON format after making a REST API call in PHP. Please give me the API that I can call. Also, share the variables and values I need to pass with the API. 

After that I wish to retrieve the campaigns, ads, etc. using the customer's ID. Is it possible?

Please help me by providing guidelines, examples and tutorials. 


Thanks,
Amit 

Google Ads API Forum Advisor Prod

unread,
May 4, 2020, 4:57:31 PM5/4/20
to ala...@nuundigital.com, adwor...@googlegroups.com

Hi Amit,

Thanks for reaching out. With regards to your concern about retrieving customer ids using a customer list, you can refer to this code example and refer to this guide

For your second concern about to retrieve campaign, ads  using customer id, you will have to make the call with a client account instead of an MCC account in order to retrieve the campaign. You can find all the examples of the Google Ads API here.

Let me know if you have any questions.

Thanks,
Nirmita Patel Google Ads Team



ref:_00D1U1174p._5004Q1zK324:ref

Amit

unread,
May 6, 2020, 9:00:28 AM5/6/20
to AdWords API and Google Ads API Forum
Hi Nirmita. 

Thank you for the reply and sharing the URLs. 

I able to retrieve the client customer list now. But I have another issue. I am getting the list as a Object. I cannot retrieve the customerId and name from the list using a loop. Please help me to find the solution. 

How do I get the customerId and name from this object?
Is it possible to convert this Object to JSON array?


Here is the response Object.
Google\AdsApi\AdWords\v201809\mcm\ManagedCustomerPage Object
(
    [entries:protected] => Array
        (
            [0] => Google\AdsApi\AdWords\v201809\mcm\ManagedCustomer Object
                (
                    [name:protected] => F
                    [customerId:protected] => XXXXXXXXXX
                    [canManageClients:protected] => 
                    [currencyCode:protected] => 
                    [dateTimeZone:protected] => 
                    [testAccount:protected] => 1
                    [accountLabels:protected] => 
                    [excludeHiddenAccounts:protected] => 
                )

            [1] => Google\AdsApi\AdWords\v201809\mcm\ManagedCustomer Object
                (
                    [name:protected] => E
                    [customerId:protected] => XXXXXXXXXX
                    [canManageClients:protected] => 
                    [currencyCode:protected] => 
                    [dateTimeZone:protected] => 
                    [testAccount:protected] => 1
                    [accountLabels:protected] => 
                    [excludeHiddenAccounts:protected] => 
                )

            [2] => Google\AdsApi\AdWords\v201809\mcm\ManagedCustomer Object
                (
                    [name:protected] => D
                    [customerId:protected] => XXXXXXXXXX
                    [canManageClients:protected] => 
                    [currencyCode:protected] => 
                    [dateTimeZone:protected] => 
                    [testAccount:protected] => 1
                    [accountLabels:protected] => 
                    [excludeHiddenAccounts:protected] => 
                )

            [3] => Google\AdsApi\AdWords\v201809\mcm\ManagedCustomer Object
                (
                    [name:protected] => C
                    [customerId:protected] => XXXXXXXXXX
                    [canManageClients:protected] => 
                    [currencyCode:protected] => 
                    [dateTimeZone:protected] => 
                    [testAccount:protected] => 1
                    [accountLabels:protected] => 
                    [excludeHiddenAccounts:protected] => 
                )

            [4] => Google\AdsApi\AdWords\v201809\mcm\ManagedCustomer Object
                (
                    [name:protected] => B
                    [customerId:protected] => XXXXXXXXXX
                    [canManageClients:protected] => 
                    [currencyCode:protected] => 
                    [dateTimeZone:protected] => 
                    [testAccount:protected] => 1
                    [accountLabels:protected] => 
                    [excludeHiddenAccounts:protected] => 
                )

            [5] => Google\AdsApi\AdWords\v201809\mcm\ManagedCustomer Object
                (
                    [name:protected] => A
                    [customerId:protected] => XXXXXXXXXX
                    [canManageClients:protected] => 1
                    [currencyCode:protected] => 
                    [dateTimeZone:protected] => 
                    [testAccount:protected] => 1
                    [accountLabels:protected] => 
                    [excludeHiddenAccounts:protected] => 
                )

        )

    [links:protected] => Array
        (
            [0] => Google\AdsApi\AdWords\v201809\mcm\ManagedCustomerLink Object
                (
                    [managerCustomerId:protected] => XXXXXXXXXX
                    [clientCustomerId:protected] => XXXXXXXXXX
                    [linkStatus:protected] => 
                    [pendingDescriptiveName:protected] => 
                    [isHidden:protected] => 
                )

            [1] => Google\AdsApi\AdWords\v201809\mcm\ManagedCustomerLink Object
                (
                    [managerCustomerId:protected] => XXXXXXXXXX
                    [clientCustomerId:protected] => XXXXXXXXXX
                    [linkStatus:protected] => 
                    [pendingDescriptiveName:protected] => 
                    [isHidden:protected] => 
                )

            [2] => Google\AdsApi\AdWords\v201809\mcm\ManagedCustomerLink Object
                (
                    [managerCustomerId:protected] => XXXXXXXXXX
                    [clientCustomerId:protected] => XXXXXXXXXX
                    [linkStatus:protected] => 
                    [pendingDescriptiveName:protected] => 
                    [isHidden:protected] => 
                )

            [3] => Google\AdsApi\AdWords\v201809\mcm\ManagedCustomerLink Object
                (
                    [managerCustomerId:protected] => XXXXXXXXXX
                    [clientCustomerId:protected] => XXXXXXXXXX
                    [linkStatus:protected] => 
                    [pendingDescriptiveName:protected] => 
                    [isHidden:protected] => 
                )

            [4] => Google\AdsApi\AdWords\v201809\mcm\ManagedCustomerLink Object
                (
                    [managerCustomerId:protected] => XXXXXXXXXX
                    [clientCustomerId:protected] => XXXXXXXXXX
                    [linkStatus:protected] => 
                    [pendingDescriptiveName:protected] => 
                    [isHidden:protected] => 
                )

        )

    [totalNumEntries:protected] => 6
    [PageType:protected] => ManagedCustomerPage
    [parameterMap:Google\AdsApi\AdWords\v201809\cm\Page:private] => Array
        (
            [Page.Type] => PageType
        )

)


Thanks,
Amit
Message has been deleted

Amit

unread,
May 6, 2020, 12:02:00 PM5/6/20
to AdWords API and Google Ads API Forum
Hi Nimita. 

Thank you for the reference URLs. 

I able to retrieve the customerId and Name successfully. 

Now I wish to retrieve the measures of Campaigns, Ads, Adsets, Keyword, Geo, Shopping, Phone Calls, Labels, Click Types, Audience Performance Report, Parental Status, etc. 

Please refer me URLs and examples from where I can get these measures. 

As for example, I wish to retrieve the below measure for Campains.

  • ·         ActiveViewImpressions
  • ·         ActiveViewMeasurableCost
  • ·         ActiveViewMeasurableImpressions
  • ·         AllConversions
  • ·         AllConversionValue
  • ·         AvgPosition
  • ·         Click Assisted Conversions
  • ·         Click Assisted Conv. Value
  • ·         Clicks
  • ·         client cost
  • ·         Conversions
  • ·         ConvertedClicks
  • ·         Cost
  • ·         CrossDeviceConversions
  • ·         Impressions
  • ·         Interactions
  • ·         Phone Calls Offline
  • ·         SumPosition
  • ·         TotalConversionValue
  • ·         VideoViews
  • ·         ViewThroughConversions
  • ·         Client Clicks (~10%<YaM)

I am waiting for your reply. 


Thanks,
Amit 



On Tuesday, May 5, 2020 at 2:27:31 AM UTC+5:30, adsapiforumadvisor wrote:

Google Ads API Forum Advisor Prod

unread,
May 6, 2020, 3:31:56 PM5/6/20
to ala...@nuundigital.com, adwor...@googlegroups.com

Hi Amit,

Thanks for reaching out. With regards to your concern about retrieving the measures of campaigns, you can use campaign performance report using different fields. Please refer to this code sample to download the report via AdWords API using AWQL. You can find all the reports here for other measures.

If you are still facing any issue, can you please share the complete report definition and customer id. Please reply privately to author options while sharing the details.



Let me know if you have any questions.

Thanks,
Nirmita Patel Google Ads Team

 



ref:_00D1U1174p._5004Q1zK324:ref
Reply all
Reply to author
Forward
0 new messages