Posts tagged with google-api

i have integrated google adsense for my client's website, ads are showing in some devices, but in some devices it showing always, particularly ads are not showing always in my client's devices,

is that any mistake i did on my google adsense account to resolve this issue, or it is the nature of google adsense?

but client's want to get ads for all devices and every time it need to show on his website,

i have tried with lots of blogs about this, everything is failed, and i'm finally here, hopefully i get a valuable knowledge here,

this is my first question on stackoverflow, if i made any mistake on it, please don't mind it, i'll correct on my future questions.

Thanks in advance.

I'm using Google Ads API v11 to upload conversions and adjust conversions. I send hundreds of conversions each day and want to start sending batch requests instead.

I've followed Google's documentation and I upload/ adjust conversions exactly the way they stated. https://developers.google.com/google-ads/api/docs/conversions/upload-clicks https://developers.google.com/google-ads/api/docs/conversions/upload-adjustments

I could not find any good explanation or example on how to send batch requests: https://developers.google.com/google-ads/api/reference/rpc/v11/BatchJobService

Below is my code, an example of how I adjust hundreds of conversions. An explanation of how to do so with batch requests would be very appreciated.

# Adjust the conversion value of an existing conversion, via Google Ads API def adjust_offline_conversion(client,     customer_id,     conversion_action_id,     gclid,     conversion_date_time,     adjustment_date_time,     restatement_value,     adjustment_type='RESTATEMENT'):     # Check that gclid is valid string else exit the function     if type(gclid) is not str:         return None     # Check if datetime or string, if string make as datetime     if type(conversion_date_time) is str:         conversion_date_time = datetime.strptime(conversion_date_time, '%Y-%m-%d %H:%M:%S')     # Add 1 day forward to conversion time to avoid this error (as explained by Google: "The Offline Conversion cannot happen before the ad click. Add 1-2 days to your conversion time in your upload, or check that the time zone is properly set.")     to_datetime_plus_one = conversion_date_time + timedelta(days=1)     # If time is bigger than now, set as now (it will be enough to avoid the original google error, but to avoid a new error since google does not support future dates that are bigger than now)     to_datetime_plus_one = to_datetime_plus_one if to_datetime_plus_one < datetime.utcnow() else datetime.utcnow()     # We must convert datetime back to string + add time zone suffix (+00:00 or -00:00 this is utc) **in order to work with google ads api**     adjusted_string_date = to_datetime_plus_one.strftime('%Y-%m-%d %H:%M:%S') + "+00:00"     conversion_adjustment_type_enum = client.enums.ConversionAdjustmentTypeEnum     # Determine the adjustment type.     conversion_adjustment_type = conversion_adjustment_type_enum[adjustment_type].value     # Associates conversion adjustments with the existing conversion action.     # The GCLID should have been uploaded before with a conversion     conversion_adjustment = client.get_type("ConversionAdjustment")     conversion_action_service = client.get_service("ConversionActionService")     conversion_adjustment.conversion_action = (         conversion_action_service.conversion_action_path(             customer_id, conversion_action_id         )     )     conversion_adjustment.adjustment_type = conversion_adjustment_type     conversion_adjustment.adjustment_date_time = adjustment_date_time.strftime('%Y-%m-%d %H:%M:%S') + "+00:00"     # Set the Gclid Date     conversion_adjustment.gclid_date_time_pair.gclid = gclid     conversion_adjustment.gclid_date_time_pair.conversion_date_time = adjusted_string_date     # Sets adjusted value for adjustment type RESTATEMENT.     if conversion_adjustment_type == conversion_adjustment_type_enum.RESTATEMENT.value:         conversion_adjustment.restatement_value.adjusted_value = float(restatement_value)     conversion_adjustment_upload_service = client.get_service("ConversionAdjustmentUploadService")     request = client.get_type("UploadConversionAdjustmentsRequest")     request.customer_id = customer_id     request.conversion_adjustments = [conversion_adjustment]     request.partial_failure = True     response = (         conversion_adjustment_upload_service.upload_conversion_adjustments(             request=request,         )     )     conversion_adjustment_result = response.results[0]     print(         f"Uploaded conversion that occurred at "         f'"{conversion_adjustment_result.adjustment_date_time}" '         f"from Gclid "         f'"{conversion_adjustment_result.gclid_date_time_pair.gclid}"'         f' to "{conversion_adjustment_result.conversion_action}"'     ) # Iterate every row (subscriber) and call the "adjust conversion" function for it df.apply(lambda row: adjust_offline_conversion(client=client                                                    , customer_id=customer_id                                                    , conversion_action_id='xxxxxxx'                                                    , gclid=row['click_id']                                                    , conversion_date_time=row['subscription_time']                                                    , adjustment_date_time=datetime.utcnow()                                                    , restatement_value=row['revenue'])                                                    , axis=1) 

I have a company which does music promotion and we are working with Google Ads experts to run campaigns for us on some Youtube Videos. We are currently tracking all the Youtube stats like comments, views, likes and etc... using the Youtube API. But we would also like to track data from the Google Ads API like campaign_budget, click_views etc...

What would be the best way to do so.

Should I create a manager account and invite the google ads expert

or Should he invite me as a client ? In this case how could he give me a token that only works for my campaigns and not for the campaigns of other of its clients ?

Thanks

Giovanni

Good morning i having a problem with google Ads api. I am coding with .net environment with client library provided by google and i followed the documentation on google site to configure api request to create campaign, group and ads automatically. I did a simple test site to test api but execution stops or better never stop but it seems in a infinite loop after call of line:

  MutateCampaignBudgetsResponse response = budgetService.MutateCampaignBudgets(customerId.ToString(), new CampaignBudgetOperation[] { budgetOperation }); 

I can't solve this problem because no exception or error is thrown. This is the link of google documentation i have followed: https://developers.google.com/google-ads/api/docs/start Thank you

client_id, client_secret, developer_token = settings.CLIENT_ID, settings.CLIENT_SECRET, settings.DEVELOPER_TOKEN credentials = oauth2.GoogleRefreshTokenClient(     client_id,     client_secret,     login_user.refresh_token ) client = GoogleAdsClient(credentials, settings.DEVELOPER_TOKEN) click_conversion = client.get_type("ClickConversion") conversion_action_service = client.get_service("ConversionActionService") click_conversion.conversion_action = (     conversion_action_service.conversion_action_path(         client_id, company.conversion_name     ) ) click_conversion.gclid = deal.gclid click_conversion.conversion_value = float(deal.deal_value if deal.deal_value else 0) click_conversion.conversion_date_time = make_aware(datetime.now()).strftime('%Y%m%d %H%M%S %z') conversion_upload_service = client.get_service("ConversionUploadService") request = client.get_type("UploadClickConversionsRequest") request.customer_id = client_id request.conversions.append(click_conversion) request.partial_failure = True conversion_upload_response = (     conversion_upload_service.upload_click_conversions(         request=request,     ) ) 

Does anyone know why I'm getting the above error when trying to Upload Clicks to google ads? got this in the logs:

Request made: ClientCustomerId: xxxxxx-xxxxx.apps.googleusercontent.com, Host: googleads.googleapis.com, Method: /google.ads.googleads.v11.services.ConversionUploadService/UploadClickConversions, RequestId: None, IsFault: True, FaultMessage: Getting metadata from plugin failed with error: 'GoogleRefreshTokenClient' object has no attribute 'before_request'