Posts tagged with google-ads-api

I am using the Google Oauth2 API to connect to Google Ads and become only one refresh token when my @gmail.com account has read access to two different Google Ads accounts.

I have the account a@gmail.com. This account has read access to the Google Ads accounts b@gmail.com and c@gmnail.com.

When I create two connections to Google Ads with the email a@gmail.com for the accounts b@gmail.com and c@gmail.com, then I receive only one refresh token, for the first connection and none refresh token for the second connection. Why? How can I manage this, to become 2 refresh tokens for each connection? The only way to become a refresh token for the second connection is to go to my account a@gmail.com and to decline the access to my app manually and connect again with c@gmail.com. But then b@gmail.com has no refresh token anymore.

code:

$oauth2 = new OAuth2(             [                 'authorizationUri' => $this->container->getParameter('oauth2.google.adwords.authorizationUri'),                 'tokenCredentialUri' => $this->container->getParameter('oauth2.google.adwords.tokenCredentialUri'),                 'redirectUri' => $this->container->getParameter('domain.system') . $this->container->getParameter(                         'oauth2.google.adwords.redirectUri.advertiser'                     ),                 'clientId' => $this->container->getParameter('oauth2.google.adwords.clientId'),                 'clientSecret' => $this->container->getParameter('oauth2.google.adwords.clientSecret'),                 'scope' => $this->container->getParameter('oauth2.google.adwords.scope')             ]         ); // Create a 'state' token to prevent request forgery.             // Store it in the session for later validation.             $randomState = sha1(openssl_random_pseudo_bytes(1024)) . '---' . $accountId;             $oauth2->setState($randomState);             // Redirect the user to the authorization URL.             $config = [                 // Set to 'offline' if you require offline access.                 'access_type' => 'offline',                 'approval_prompt' => 'force'             ];             // redirect to google ads             return new RedirectResponse($oauth2->buildFullAuthorizationUri($config)); 

Is there a way in Flutter to get the install referrer from google play? https://developer.android.com/google/play/installreferrer/library.html if possible both Android and iOS.

My Goal is to identify if the user was installed/downloaded from Play Store Search, on our Website, and in our Google Ads. For our Play Store Search and on Our Website Download/Install is already handled by Firebase Dynamic Links.

My Current Problem was about the Google Ads Universal App Campaign. I can't attach links in Universal App Campaign.

After exhausting all options, I'm hoping for some help. I am trying to adjust my script to remove all targeted locations for a specific campaign. The problem is, the only way I've found to do it is to iterate through each targeted location and remove them one by one. If a campaign has 2000 location targets, this takes far too long and the script times out.

Below is an example of the standard script used to remove them one by one. Any suggestions on how to speed this up? Is it possible to pass an array of campaign specific locationIDs in and have it remove them all in one shot? Or, is there a function available to remove ALL locations at once? Either of these methods would work for me but I haven't been able to find a solution that accomplishes this.

Thanks in advance for your help

function removeTargetedLocations(campaign) {     var campaignIterator = AdWordsApp.campaigns()         .withCondition('Name = ' + campaign + '')         .get();     if (campaignIterator.hasNext()) {         var campaign = campaignIterator.next();         var locationIterator = campaign.targeting().targetedLocations().get();         while (locationIterator.hasNext()) {             var loc = locationIterator.next();             loc.remove();         }     } } 

I have an ads script which exports data to a sheet based on rules.

However, I only want to replace data within a certain cell range such as 'A2:J' within a Google sheet.

I know how to do this within spreadsheetApp script but unsure/struggling on Ads script/AWQL.

I have pasted the basics of the script below but really could do with insight into whether and how it is possible to push to a specific range.

function main(){ // Put your Google data sheet here var sheetURL = ''; // Enter the tab name here var tabName = ''; var QUERIES = [{'query' : 'SELECT Date, DayOfWeek, HourOfDay, Device, CampaignName, Impressions, Clicks, Cost, Conversions, ConversionValue ' +                         'FROM CAMPAIGN_PERFORMANCE_REPORT ' +             'WHERE Impressions > 0 ' +                       'DURING TODAY',                       //'DURING ' + dateRanges,             'spreadsheetUrl' : sheetURL,             'tabName' : tabName,             'reportVersion' : 'v201809'            }                       ]; //This is to gather the above query and push it to the spreadsheet stated above   for(var i in QUERIES) {     var queryObject = QUERIES[i];     var query = queryObject.query;     var spreadsheetUrl = queryObject.spreadsheetUrl;     var tabName = queryObject.tabName;     var reportVersion = queryObject.reportVersion;     //Logger.log(spreadsheetUrl + " " + query);     var spreadsheet = SpreadsheetApp.openByUrl(spreadsheetUrl);     var sheet = spreadsheet.getSheetByName(tabName);     var report = AdWordsApp.report(query, {apiVersion: reportVersion});     report.exportToSheet(sheet);   } } 

I am trying to disable caching with zeep as is described here: https://github.com/googleads/googleads-python-lib/blob/master/README.md#how-can-i-configure-or-disable-caching

adwords_client = adwords.AdWordsClient(   developer_token, oauth2_client, user_agent,   client_customer_id=client_customer_id,   cache=googleads.common.ZeepServiceProxy.NO_CACHE) 

But I lack understanding of what I should provided ot AdWordsClient as ‘oauth2_client’ attribute.

I am trying to find the solution here http://googleads.github.io/googleads-python-lib/googleads.oauth2.GoogleOAuth2Client-class.html but without success so far.

I am using For OAuth2 process google_auth_oauthlib and I managed retrieved refresh token, but at this point I am kinda lost, because due to the fact that I am running it on GCP App Engine, I am not able to use googleads.yaml file.

Can somebody enlighten me in a case of this oauth2_client?

Thanks sincerely!