Posts under category Google

The app is crashing on launch after implementing google ads. I'm using an ios simulator. Ads are working fine on the other apps with the same code implementation but not on this app. Others apps are displaying test ads even with original Ad Units IDs. Interstitial Ads and Rewarded Ads are working fine only banner ads got the issue.

The error: To get test ads on this device, set: Objective-C GADMobileAds.sharedInstance.requestConfiguration.testDeviceIdentifiers = @[ kGADSimulatorID ]; Swift GADMobileAds.sharedInstance().requestConfiguration.testDeviceIdentifiers = [ kGADSimulatorID ]

Code: AdHelper Class

import 'package:google_mobile_ads/google_mobile_ads.dart'; import 'dart:io'; class AdHelper{   //  Android Ad Units   static String _bannerAd_And = 'ca-app-pub-3884661730977437/3917788070';   static String _interAd_And = 'ca-app-pub-3884661730977437/1291624734';   static String _bannerAdTest_And = 'ca-app-pub-3940256099942544/6300978111';   static String _interAdTest_And = 'ca-app-pub-3940256099942544/1033173712';   //  iOS Ad Units   static String _bannerAd_iOS = 'ca-app-pub-3884661730977437/4131225272';   static String _interAd_iOS = 'ca-app-pub-3884661730977437/6845018522';   static String _bannerAdTest_iOS = 'ca-app-pub-3940256099942544/2934735716';   static String _interAdTest_iOS = 'ca-app-pub-3940256099942544/4411468910'; // FN returns Banner AD Unit Id   static String get bannerAdUnitId {     if (Platform.isAndroid) {       return _bannerAdTest_And;     } else if (Platform.isIOS) {       return _bannerAdTest_iOS;     } else {       throw UnsupportedError('Unsupported platform');     }   }   // FN returns Interstitial Ad Unit Id   static String get interAdUnitId {     if (Platform.isAndroid) {       return _interAdTest_And;     } else if (Platform.isIOS) {       return _interAdTest_iOS;     } else {       throw UnsupportedError('Unsupported platform');     }   } } 

AdController

import 'package:get/get.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart'; import 'AdMob_Helper.dart'; class AdMobController extends GetxController{   ///------------------  Init   @override   void onInit() {     getBannerAd();     super.onInit();   }   ///------------------  Dispose   @override   void onClose() {     bannerAd.dispose();     super.onClose();   }   late BannerAd bannerAd;   bool isBannerLoaded = false;   //   void getBannerAd() {     bannerAd = BannerAd(       adUnitId: AdHelper.bannerAdUnitId,       size: AdSize.banner,       request: AdRequest(),       listener: BannerAdListener(         onAdLoaded: (_) {           isBannerLoaded = true;           update();         },         onAdFailedToLoad: (ad, error) {           // Releases an ad resource when it fails to load           ad.dispose();           print('Ad load failed (code=${error.code} message=${error.message})');         },       ),     );     // TODO: Load an ad     bannerAd.load();     update();   } } 

I am trying to use Google Ads on Google Apps Script using this guide. I created client id and client secret on Google Console's API & Services.

Not too sure if this configuration is correct but the account is linked to Google Apps Script as I have pagespeed insights as well and there are some requests on the dashboard. I added https://www.googleapis.com/auth/drive as the scope. Again not too sure if I should add Google Ads to the scope. Lastly, got my refresh token from Google Auth playground. When I run the script above I got the following error:

Error: No access token received: {   "error": "invalid_client",   "error_description": "Unauthorized" } authenticate_   @ test.gs:120 withRefreshToken    @ test.gs:144 initializeOAuthClient   @ test.gs:28 

Honestly not too sure what I am doing wrong here so any help would be very much appreciated. Thank you.

Edit Codes:

//From Google Console API & Services var CLIENT_ID = '"MY_CLIENT_ID'; var CLIENT_SECRET = 'MY_CLIENT_SECRET'; //From Google Authplayground var REFRESH_TOKEN = 'REFRESH_TOKEN'; // Enter scopes which should match scopes in File > Project properties // For this project, e.g.: https://www.googleapis.com/auth/drive var SCOPES = "https://www.googleapis.com/auth/adwords"; // Script ID taken from 'File > Project Properties' var SCRIPT_ID = 'MY_SCRIPT_ID'; var authUrlFetch; // Call this function just once, to initialize the OAuth client. function initializeOAuthClient() {   if (typeof OAuth2 === 'undefined') {     var libUrl = 'https://developers.google.com/google-ads/scripts/docs/examples/oauth20-library';     throw Error('OAuth2 library not found. Please take a copy of the OAuth2 ' +         'library from ' + libUrl + ' and append to the bottom of this script.');   }   var tokenUrl = 'https://accounts.google.com/o/oauth2/token';   authUrlFetch = OAuth2.withRefreshToken(tokenUrl, CLIENT_ID, CLIENT_SECRET,     REFRESH_TOKEN, SCOPES); } /**  * Execute a remote function.  * @param {string} remoteFunctionName The name of the function to execute.  * @param {Object[]} functionParams An array of JSON objects to pass to the  *     remote function.  * @return {?Object} The return value from the function.  */ function executeRemoteFunction(remoteFunctionName, functionParams) {   var apiParams = {     'function': remoteFunctionName,     'parameters': functionParams   };   var httpOptions = {     method: 'POST',     headers: {       'Content-Type': 'application/json'     },     payload: JSON.stringify(apiParams)   };   var url = 'https://script.googleapis.com/v1/scripts/' + SCRIPT_ID + ':run';   var response = authUrlFetch.fetch(url, httpOptions);   var data = JSON.parse(response.getContentText());   // Retrieve the value that has been returned from the execution.   if (data.error) {     throw Error('There was an error: ' + response.getContentText());   }   return data.response.result; } // Paste in OAuth2 library here, from: // https://developers.google.com/google-ads/scripts/docs/examples/oauth20-library 

I have pasted the oauth2.0 library under the codes above.

Edit 2
I fixed the part of function initializeOAuthClient. It now shows execution complete, but when I try to run function executeRemoteFunction I am getting TypeError: Cannot read property 'fetch' of undefined. I am guessing I have to input remoteFunctionName and functionParams but where do I find them?

I'm using Google Tag Manager to set a Google Ads conversion tag in my website. When I was debugging using the Tag Assistant window from GTM, my conversion tag was fired successful. When I opened the Tag Assistant Legacy extension from Chrome, I found two error messages related to the "Google Ads Conversion Tracking" tag:

  • "An error occured while the tag was fired: net::ERR_ABORTED"
  • "Error while sending request: net::ERR_ABORTED"

How can I solve this error messages?

Other tags such as "Google Tag Manager", "Global Site Tag (gtag.js)" or "Remarketing Tag" had no errors.

My site is https://mardemor.com.br

Thanks

At the moment I am getting stats this way:

    $adWordsServices = new AdWordsServices();     $session = (new AdWordsSessionBuilder())->fromFile($this->account->token)->withOAuth2Credential($this->oAuth2Credential)         ->build();     $managedCustomerService = $adWordsServices->get(         $session,         ManagedCustomerService::class     );     // Create selector.     $selector = new Selector();     $selector->setFields(['CustomerId', 'Name']);     $selector->setOrdering([new OrderBy('CustomerId', SortOrder::ASCENDING)]);     $selector->setPaging(new Paging(0, 100)); 

but how to get statistics for all accounts active and inactive? This code returns only list of active accounts.