Posts tagged with google-ads-api

I have always referred to to Adwords API (https://developers.google.com/adwords/api/docs/appendix/reports) as a guide for exporting reports from Google Ads. When moving to new Ads API (https://developers.google.com/google-ads/api/fields/v6/overview) I was confused with the new feature "resources" which is the alternative for "old" reports.

Some reports in Adwords API match these resources in Ads API (Ad Group Performance) but I am unable to find matches for Account Performance Report and Criteria Performance Report. I'm not also sure that Audience Performance Report is similar to Campaign Audience View.

Can someone please explain how I can export these unmatched reports using Ads API? Thanks!

I'm trying to figure out if this works. Unfortunately I do not have a website to test this with. Though I've read the GA and GAds documentation I'm not sure if this is possible. So please bear with me.

Imagine a simple website that has Google Analytics (with a linked GAds account) deployed. I want to run a survey on this site users can answer if they like to. As the result of the survey the participants are assigned some ID. Lets say the result variable is called cluster and the values are A, B or C.

What I want to do now, is use this group of participants of the survey and try to target new visitors that are similar to the ones that have been assigned a C value via Google Ads.

As far as I understood the documentations this is how it could be done. Please correct me and point me in the right direction if I'm wrong.

  1. I'm setting up a custom user dimension called Cluster in GA
  2. I'm editing the GA code on the website to include the custom dimension that will be populated with the result of the mentioned survey
  3. When the results come into GA, I'm creating a remarketing audience in GA called Cppl based on the custom dimension Cluster
  4. I'm importing this Cppl remarketing audience into GAds
  5. I'm creating a similar audience in GAds based on Cppl list
  6. I'm publishing a campaign based on this similar audience

Does this process make sense and is it correct or am I making any mistakes?

I'm trying to set html content of a new element but when I check to see if slot.getHtml() gives me the html element (set below), it shows an empty string. Any idea why this could be happening?

var slot = googletag.defineSlot('/1234567/sports', [160, 600], 'ozge')   .addService(googletag.companionAds())   .addService(googletag.pubads())   .addService(googletag.content()); googletag.content().setContent(slot, '<h2>Custom content in ad slot.</h2>') 

I use the code snippet in this link to view the newly defined slot: https://gist.github.com/rdillmanCN/a70ec955d9a982127fefadabe8b898b5

I'm trying to create an AdGroupAd using an existing groupAd, and i'm getting a "segmentation fault" error message I've been at this for more than a day now, but the lack of details on the error just makes this insane to understand what's wrong

running on docker

Client library: v5.0.0

Google Ads API: v5.0

PHP 7.4.12 (cli) (built: Nov 5 2020 20:24:10) ( NTS )

Zend Engine v3.4.0,

ionCube PHP Loader + ionCube24 v10.4.4

Zend OPcache v7.4.12

protobuff 3.14.0

grpc 1.33.1

my code: Assume createAdGroupAd() is called with a valid resource name for an adGroup in the $adGroup parameter and the type is CreativeType_Asset::TYPE_YOUTUBE in this case (although i tried with both types and both give out the error)

public function createAdGroupAd($adGroup, $data){         $service = $this->client->getAdGroupAdServiceClient();         $ad = $this->createAd($data, $data['asset']->type);         $adGroupAd = new AdGroupAd([             'ad' => $ad,             'status' => AdGroupAdStatus::PAUSED,             'ad_group' =>  $adGroup         ]);         $adGroupAdOperation = new AdGroupAdOperation();         $adGroupAdOperation->setCreate($adGroupAd);         //this is the call causing the error         $response = $service->mutateAdGroupAds(             $this->customerId,             [$adGroupAdOperation]         );         return $response->getResults()->count() > 0 ? $response->getResults()[0]->getResourceName() : null;     }     public function createAd($data, $adType = null){         $service = $this->client->getAdServiceClient();         $appAdInfo = new AppAdInfo([             'headlines' => array_map(function ($headline) {                 new AdTextAsset(['text' => $headline]);             }, [$data['creative']->title1, $data['creative']->title2]),             'descriptions' => array_map(function ($description) {                 new AdTextAsset(['text' => $description]);             }, [$data['creative']->description1, $data['creative']->description2])         ]);         switch ($adType) {             case CreativeType_Asset::TYPE_IMAGE:                 $appAdInfo->setImages([new AdImageAsset(['asset' => $data['assetResourceName']])]);                 break;             case CreativeType_Asset::TYPE_YOUTUBE:                 $appAdInfo->setYoutubeVideos([new AdVideoAsset(['asset' => $data['assetResourceName']])]);                 break;             default:                 break;         }         return new Ad([             'app_ad' => $appAdInfo,             'type' => AdType::APP_AD]);     } 

I am trying to work with Google-ads-API. Running Ubuntu 20.04, Python 3.9(min requirement for the client library to work is 3.6), working with google-ads-api V6. Here's the story of my agony.

I have made a test manager account[A], generated a developer's token, and have "test-level" access to use the API, which is great. Test level allows you to make calls to the API regarding information\reports dealing with test accounts(not production).

Also, went through the whole Oauth2 credentials for account [A], allowed test emails, and after running "examples/authentication/authenticate_in_web_application.py", I am redirected to a webpage, allow my main test manager account to access the second test manager account[B](as instructed by the documentation, to create another test manager account[B], besides the main account[A] with the developer token), a refresh token is generated successfully from this OAuth2 prompt, to allow account [B] to be managed my account [A], added the refresh token to my google-ads.yaml file, and things are all good.

When I run this .py file from the examples

python3 google-ads-python/examples/account_management/list_accessible_customers.py 

The result is this:

Total results: 2 Customer resource name: "customers/1792845307" Customer resource name: "customers/5341438919" 

Lovely, took 2 days to get this far. And it's been two days now trying to get past the following. Please note that the above results are both from my account [B], the API request to get these results was made while the developer token for account [A] is set in the google-ads.yaml file.

So, the .yaml file for now contains Developer account token for account [A], OAuth creds for account[A] on cloud console(.json) file. The refresh token for account [B] that resulted from the Authentication in step1.

Moving on, by running "get_account_information.py", which is also in the examples folder, and passing to it one of the accounts from the above result[mandatory flag --c, which is the client id), I keep getting an access denied error:

python3 get_account_information.py --c 5341438919 I get this:

Request with ID "LhKeU9ZI4zZgnp05VSHbjg" failed with status "PERMISSION_DENIED" and includes the following errors: Error with message "User doesn't have permission to access customer. Note: If you're accessing a client customer, the manager's customer id must be set in the 'login-customer-id' header. See https://developers.google.com/google-ads/api/docs/concepts/call-structure#cid".``` 

I have tried setting "the manager's customer id must be set in the 'login-customer-id' ", this login-customer-id is located in the .yaml file. I have tried setting that to both the results from the call in step 2. I also tried adding the account manager ID from account[A]. I tried manually adding account [A] as an account manager for account [B] from withing google-ads's UI, then tried setting the "login-customer-id" again for all these accounts these linking processes, yet, failed miserably.

I am facing this access denied for all the .py files in the example directory. Tried to be as thorough and verbose as possible for this lengthy process, hoping it'll make sense. If you have tried to work with this API, you will understand what I mean, and I look forward to any insight\help\input regarding this, even if you haven't worked with this API.

In the documentation, the guide says that after creating a test developer manager account, all accounts below that will be also test accounts, and will be designated by a red label saying "TEST", otherwise it's a production account. Both accounts [A]+[B] above are test manager\developer accounts, yet don't have any red labels stating they are tests, neither any children I tried creating under them. So I wonder if the error\roadblock I am facing is due to them not being designated as test accounts? But why are they being listed as "Accessible accounts" in Step2.

Thanks a lot! If any other pieces of info should be required, I shall provide.