Posts tagged with google-ads-api

I have a Looker Studio dashboard that was working with no issue before. For the past few months it shows the following error:

Metric results might not be accurate when using Asset level dimensions. Please add "Ad Type" and "Asset ID" fields to get accurate data. 

I'm using blended data which is blending Google Sheets with Google Ads. This issue persists even if I add "Ad Type" and "Asset ID" to this data.

How can I either solve or hide this error? (at least hiding it would help getting rid of this annoying error).

I tried adding "Ad Type" and "Asset ID" to this data. Or Event rebuilding the tables joins by adding a new Google Ads to it so I get these fields from the new data source.

I'm encountering an issue with the Google Ads API where I'm receiving the following error message:

Credentials failed to obtain metadata

This error occurs when making requests to the Google Ads API using the GoogleAdsService/Search method. Here's an example of the request and response details:

Request

MethodName: google.ads.googleads.v16.services.GoogleAdsService/Search Endpoint: googleads.googleapis.com:443 Headers: {developer-token=REDACTED, login-customer-id=9854212609, x-goog-api-client=gl-java/17.0.10__Oracle-Corporation gccl/31.0.0 gapic/31.0.0 gax/2.47.0 grpc/1.62.2} Body: customer_id: "9854212609" query: "SELECT campaign.id, campaign.name FROM campaign" 

Response

Headers: null Body: null Failure message: null Status: Status{code=UNAVAILABLE, description=Credentials failed to obtain metadata, cause=com.google.auth.oauth2.GoogleAuthException: com.google.api.client.http.HttpResponseException: 401 Unauthorized POST https://oauth2.googleapis.com/token 

...

Here are the details of my configuration:

  • I'm using Spring Boot for my application.
  • I have a google-ads.properties file where I've configured the necessary credentials such as clientId, clientSecret, refreshToken, developerToken, and loginCustomerId.
  • I've implemented the Google Ads client using the GoogleAdsClient class provided by the Google Ads Java library.
  • I've verified that the credentials are correct and have the necessary permissions to access the Google Ads API.

Despite these configurations, I'm still encountering the error mentioned above. I'm not sure what could be causing the issue. Any insights or suggestions on how to troubleshoot and resolve this would be greatly appreciated.

Thank you in advance for your help!

based on the provided error message and the details of the configuration, I expected the Google Ads API requests to authenticate successfully and return the requested data. However, the actual result was a failure with the message "Credentials failed to obtain metadata," indicating an authentication issue.

I want to add Google Analytics and Google Adsense to my website in NextJS. I found this official doc: https://nextjs.org/docs/app/building-your-application/optimizing/third-party-libraries#google-tag-manager

According to this, its enough to add:

 <GoogleTagManager gtmId="GTM-XYZ" /> 

However, I have problem with understanding how Google adsense works. I know that google adsense require from me to include another script to my head (my account is not approved yet for google ads). The problem is that I want to let user decide whether he accepts analytics and advertisement cookies. I was going to simply remove GoogleTagManager from my head for analytics but what with advertsiement? I.e. I can't remove the Google Ads script because I dont want to remove ads at all so have can I distinguish between "personalized adverts" (user accepted cookies) and "not personalized" adverts? How should I construct my code to handle all cases?

I try to exclude a placement via code and I get this error (read bottom up):

DEFAULT 2024-06-03T13:34:05.278214Z index: 251 DEFAULT 2024-06-03T13:34:05.278211Z field_name: "operations" DEFAULT 2024-06-03T13:34:05.278208Z field_path_elements { DEFAULT 2024-06-03T13:34:05.278203Z location { DEFAULT 2024-06-03T13:34:05.278200Z } DEFAULT 2024-06-03T13:34:05.278197Z string_value: "mixnews.lv/news/2024/04/09/dich-na-pervom-svidanii-kakie-momenty-stali-navsegda-v-pamyati-devushek" DEFAULT 2024-06-03T13:34:05.278192Z trigger { DEFAULT 2024-06-03T13:34:05.278189Z message: "Placement URL has wrong format." DEFAULT 2024-06-03T13:34:05.278185Z } DEFAULT 2024-06-03T13:34:05.278181Z criterion_error: INVALID_FORMAT_FOR_PLACEMENT_URL DEFAULT 2024-06-03T13:34:05.278177Z error_code { 

How can I understand what's wrong in this format?

I'm trying to create an display upload ad in Google Ads API v14, but I'm encountering issues. Specifically, I'm getting an "INVALID_ARGUMENT" error with the message "Mutates are not allowed for the requested resource."

def create_display_upload_ad_group_ad(client, customer_id, ad_group_id, ad_asset_resource_name):     """Creates a new HTML5 display upload ad and adds it to the given ad group.     Args:         client: An initialized Google Ads client.         customer_id: The Google Ads customer ID.         ad_group_id: The ID of the ad group to which the new ad will be added.         ad_asset_resource_name: The resource name of the media bundle containing             the HTML5 components.     """     # Get the AdGroupAdService client.     ad_group_ad_service = client.get_service("AdGroupAdService")     # Create an AdGroupAdOperation.     ad_group_ad_operation = client.get_type("AdGroupAdOperation")     # Configure the ad group ad fields.     ad_group_ad = ad_group_ad_operation.create     ad_group_ad.status = client.enums.AdGroupAdStatusEnum.PAUSED     ad_group_ad.ad_group = client.get_service("AdGroupService").ad_group_path(         customer_id, ad_group_id     )     # Configured the ad as a display upload ad.     display_upload_ad = ad_group_ad.ad     display_upload_ad.name = "Ad for HTML5"     display_upload_ad.final_urls.append("http://example.com/html5")     # Exactly one of the ad_data "oneof" fields must be included to specify the     # ad type. See: https://developers.google.com/google-ads/api/reference/rpc/latest/Ad for     # the full list of available types. By setting a "display_upload_ad"     # subfield it sets that as the "oneof" field for the Ad.     display_upload_ad.display_upload_ad.media_bundle.asset = (         ad_asset_resource_name     )     display_upload_ad.display_upload_ad.display_upload_product_type = (         client.enums.DisplayUploadProductTypeEnum.HTML5_UPLOAD_AD     )     # Add the ad group ad to the client account and display the resulting     # ad's resource name.     mutate_ad_group_ads_response = ad_group_ad_service.mutate_ad_group_ads(         customer_id=customer_id, operations=[ad_group_ad_operation]     )     print(         "Created new ad group ad with resource name "         f"'{mutate_ad_group_ads_response.results[0].resource_name}'."     ) 

Error Message:

Request with ID "xKDxTq8R83Lu7ElSsLBwYw" failed with status "INVALID_ARGUMENT" and includes the following errors: Error with message "Mutates are not allowed for the requested resource.".         On field: operations         On field: create         On field: ad 

file was uploaded and returned the path Uploaded file with resource name 'customers/12344/assets/12234' and I entered it in the function's ad_asset_resource_name
i try to v14

Despite these checks, I'm still encountering the same error. Any insights or suggestions on what might be going wrong would be greatly appreciated.