Comments (2)
Hi @shivam-2002 thanks for pointing this out. This looks like a typo, there is indeed no example called get_ad_groups
. I'll remove that line, meanwhile if you want to retrieve ad groups see the ad_group
resource.
To be more specific, if you want to get all the ad groups for an account, you can follow the get_campaigns
example, but use the below query instead:
SELECT
ad_group.id,
ad_group.name
FROM ad_group
from google-ads-python.
Than You Ben for your kind attention, I already have written the code for above. If you want you can attach a new file get_ad_groups.py.
import argparse
import sys
from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException
def main(client, customer_id):
# Get the GoogleAdsService client.
googleads_service = client.get_service("GoogleAdsService")
query = f"""
SELECT
ad_group.id,
ad_group.name
FROM ad_group
"""
search_response = googleads_service.search(
customer_id=customer_id, query=query
)
for res in search_response:
print(res)
if __name__ == "__main__":
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v15")
parser = argparse.ArgumentParser(
description="Updates the audience target restriction of a given ad "
"group to bid only."
)
# The following argument(s) should be provided to run the example.
parser.add_argument(
"-c",
"--customer_id",
type=str,
required=True,
help="The Google Ads customer ID.",
)
args = parser.parse_args()
try:
main(googleads_client, args.customer_id)
except GoogleAdsException as ex:
print(
f'Request with ID "{ex.request_id}" failed with status '
f'"{ex.error.code().name}" and includes the following errors:'
)
for error in ex.failure.errors:
print(f'\tError with message "{error.message}".')
if error.location:
for field_path_element in error.location.field_path_elements:
print(f"\t\tOn field: {field_path_element.field_name}")
sys.exit(1)
Hi @shivam-2002 thanks for pointing this out. This looks like a typo, there is indeed no example called
get_ad_groups
. I'll remove that line, meanwhile if you want to retrieve ad groups see thead_group
resource.To be more specific, if you want to get all the ad groups for an account, you can follow the
get_campaigns
example, but use the below query instead:SELECT ad_group.id, ad_group.name FROM ad_group
from google-ads-python.
Related Issues (20)
- StatusCode.PERMISSION_DENIED HOT 1
- Keyword Historical Metric - RESOURCE_EXHAUSTED HOT 3
- Ad Accounts Suspensions Following Campaign Pausing HOT 1
- Response is None for offline_user_data_job_service_client.add_offline_user_data_job_operations HOT 1
- PMax Listing Group Status and Asset Group ID Discrepancy HOT 2
- API GOOGLES ADS REAL-TIME HOT 1
- Adding Consent Field To OfflineUserDataJobOperation Job HOT 4
- Google Ads API: CUSTOMER_MATCH_WITH_ATTRIBUTES Job Type does not populate audience HOT 1
- Parameter to MergeFrom() must be instance of same class HOT 1
- Google Ads library version 23.1.0 has a compatibility issue with AWS lambda. HOT 1
- Get All Campaigns Based on Given Example returns Nothing HOT 2
- IsFault: True, FaultMessage: Combined audience ID is invalid HOT 1
- Google Ads API Python SDK v16 support HOT 2
- keyword ideas different results from the web interface HOT 1
- Campaign budget operation update results in SIGSEGV HOT 1
- Unable to clear portrait_marketing_images under discovery_multi_asset_ad HOT 1
- TypeError: exceptions must derive from BaseException HOT 2
- Cannot Remove Specific App Ad Asset under Campaign's AdGroup using AdService HOT 2
- Error with GenerateKeywordHistoricalMetricsRequest HOT 1
- Warning: Scope has changed from "https://www.googleapis.com/auth/adwords" to "https://www.googleapis.com/auth/userinfo.profile openid https://www.googleapis.com/auth/adwords https://www.googleapis.com/auth/userinfo.email".
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-ads-python.