Posts tagged with google-api

I am attempting to pull in a users account hierarchy after I've received their three credentials through Oauth access ('client_id','client_secret','refresh_token'). Google API code sample I am referring to: https://developers.google.com/adwords/api/docs/samples/python/account-management#get-the-account-hierarchy-under-the-current-account

When I attempted to do this with my own account I had signed up with, client_customer_id was not needed in the .yml file, and I was successfully able to pull in the account hierarcy. When an account that was not associated with my original email gave oauth access I received an googleads.errors.GoogleAdsServerFault: [AuthorizationError.NO_CUSTOMER_FOUND @ ].

This error went away when I included their client_customer_id manually into the yml file. I feel as though I'm in a Catch-22, I need a client_customer_id to access the client_customer_id??

So, my question is, how can I pull in the client_customer_id that will give me access to the account hierarchy?

I am working with the GEO_PERFORMANCE_REPORT in order to fetch data related to the account locations. More specifically, the report I am working with is the User Locations Report, which can be found directly on the AdWords UI.

But I found out that there are some notorious differences for the data obtained via the AdWords API and the data shown via the AdWords UI, and the issues happen specifically with the aforementioned report, but also with the “Geographic Report”. I have applied the corresponding filters for the query, just as it's stated on the official documentation (1 and 2), but even with that, the data differs a lot between both sources.

The query I am constructing ends up being the following one:

Google\AdsApi\AdWords\Query\v201809\ReportQuery {#7426   -awqlString: "SELECT CampaignId, LocationType, Clicks, Impressions, CityCriteriaId, MostSpecificCriteriaId, CountryCriteriaId FROM GEO_PERFORMANCE_REPORT WHERE LocationType = 'LOCATION_OF_PRESENCE' AND IsTargetingLocation IN ['TRUE', 'FALSE'] DURING 20200401,20200430" } 

And the results I am getting (after sorting them by the Clicks metric) are the following: https://www.dropbox.com/s/6xpme91ig6wu1oy/Screenshot%202020-05-13%2018.18.43.png?dl=0. But on the AdWords UI I get the following: https://www.dropbox.com/s/cgtyglbs87lkb1p/Screenshot%202020-05-13%2018.20.20.png?dl=0.

I can see that there are similar issues open at the AdWords forum (1 and 2), but none of them seem fully solved.

Finally, based in the https://developers.google.com/adwords/api/docs/appendix/geotargeting documentation and in some other tests I did by using the MostSpecificCriteriaId, I have the theory that this could be an issue with the zipcodes mapping on the API.

Do you know what is the reason of the discrepancy for the click counts (and also for the impression counts) between both sources of these report?. Help will be appreciated.

I tried with google ads api npm with the query

SELECT ad_group_ad.ad.name, ad_group_ad.ad.type , ad_group_ad.ad.app_ad.headlines,ad_group_ad.ad.app_engagement_ad.headlines,ad_group_ad.ad.text_ad.headline FROM ad_group_ad

Response

{ ad: { resource_name: 'customers/xxxxx/ads/xxxxxx', type: 3 }, resource_name: 'customers/xxxxx/adGroupAds/xxxx~xxxxxx }

But response not containing ad name. Ad Id and resource name is there.

How can I get the ad name?

Google Ads API, Their new version of the Google Adwords API returns data in a format called "GoogleAdsRow". I have not found any use at all for the information to be presented in this format and it is quite confusing. I want to print my file to a basic .csv format, but there is not any type of delimiter as far as i can tell. S far I have only been able to print each entire row as a single cell. Not Helpful :-).

My main function looks like this following. I have provided two examples of what I have tried with a comment block identifying both attempts:

def main(client, customer_id, page_size):     ga_service = client.get_service('GoogleAdsService', version='v2')     query = ('SELECT ad_group.id, ad_group_criterion.type, '              'ad_group_criterion.criterion_id, '              'ad_group_criterion.keyword.text, '              'ad_group_criterion.keyword.match_type FROM ad_group_criterion '              'WHERE ad_group_criterion.type = KEYWORD')     results = ga_service.search(customer_id, query=query, page_size=page_size)     try:         with open(path, "w", encoding = "utf-8", newline = "") as f:         #with open(path, "w") as csv:             csv_writer = csv.writer(f, delimiter=',')             for row in results:                 campaign = row.campaign                            csv_writer.writerow([row]) #Prints entire returned row as a single cell                 csv_writer.writerow(row) #Tells me there is no delimiter 

The iterable error is as follows

<ipython-input-15-e736ee2d05c9> in main(client, customer_id, page_size)      17                 campaign = row.campaign      18                 #csv_writer.writerow([row]) #Prints entire returned row as a single cell ---> 19                 csv_writer.writerow(row) #Tells me there is no delimiter      20       21  Error: iterable expected, not GoogleAdsRow