### Query for Resource Attributes Source: https://developers.google.com/google-ads/api/docs/query./google-ads/api/docs/query/overview This example demonstrates how to retrieve basic attributes of the campaign resource, specifically its ID, name, and status. The results are ordered by campaign ID. ```APIDOC ## SELECT campaign.id, campaign.name, campaign.status FROM campaign ORDER BY campaign.id ### Description This query retrieves the ID, name, and status of campaigns. The results are ordered by campaign ID. Each returned `GoogleAdsRow` will represent a `campaign` object with the selected fields populated, including its `resource_name`. ### Method SELECT ### Endpoint Not applicable (Query Language) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```sql SELECT campaign.id, campaign.name, campaign.status FROM campaign ORDER BY campaign.id ``` ### Response #### Success Response (200) - **GoogleAdsRow** (object) - Represents a resource with selected fields. - **campaign.id** (int64) - The ID of the campaign. - **campaign.name** (string) - The name of the campaign. - **campaign.status** (enum) - The status of the campaign. #### Response Example ```json { "results": [ { "campaign": { "resourceName": "customers/12345/campaigns/67890", "id": 67890, "name": "Example Campaign Name", "status": "ENABLED" } } ] } ``` ``` -------------------------------- ### Query for Metrics Source: https://developers.google.com/google-ads/api/docs/query./google-ads/api/docs/query/overview This example shows how to query for campaign attributes along with associated metrics, such as impressions. It includes filtering for paused campaigns with more than 1000 impressions and ordering the results by campaign ID. ```APIDOC ## SELECT campaign.id, campaign.name, campaign.status, metrics.impressions FROM campaign WHERE campaign.status = 'PAUSED' AND metrics.impressions > 1000 ORDER BY campaign.id ### Description This query retrieves the ID, name, status, and impressions for campaigns that are paused and have more than 1000 impressions. The results are ordered by campaign ID. Each returned `GoogleAdsRow` will include a `metrics` field populated with the selected metrics. ### Method SELECT ### Endpoint Not applicable (Query Language) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```sql SELECT campaign.id, campaign.name, campaign.status, metrics.impressions FROM campaign WHERE campaign.status = 'PAUSED' AND metrics.impressions > 1000 ORDER BY campaign.id ``` ### Response #### Success Response (200) - **GoogleAdsRow** (object) - Represents a resource with selected fields and metrics. - **campaign.id** (int64) - The ID of the campaign. - **campaign.name** (string) - The name of the campaign. - **campaign.status** (enum) - The status of the campaign. - **metrics.impressions** (int64) - The number of impressions for the campaign. #### Response Example ```json { "results": [ { "campaign": { "resourceName": "customers/12345/campaigns/11223", "id": 11223, "name": "Paused Campaign Over 1k Impressions", "status": "PAUSED" }, "metrics": { "impressions": 1500 } } ] } ``` ``` -------------------------------- ### Querying Attributes of a Related Resource Source: https://developers.google.com/google-ads/api/docs/query./google-ads/api/docs/query/overview This section explains how to join against other related resources (attributed resources) implicitly by selecting an attribute in your query. It provides an example of selecting campaign attributes and bidding strategy attributes. ```APIDOC ## SELECT Related Resource Attributes ### Description Queries for attributes of a given resource and joins against related attributed resources by selecting their attributes. ### Method SELECT ### Endpoint N/A (This is a query language example) ### Parameters #### Query Parameters - **campaign.id** (integer) - Optional - The ID of the campaign. - **campaign.name** (string) - Optional - The name of the campaign. - **campaign.status** (string) - Optional - The status of the campaign. - **bidding_strategy.name** (string) - Optional - The name of the bidding strategy associated with the campaign. ### Request Example ```sql SELECT campaign.id, campaign.name, campaign.status, bidding_strategy.name FROM campaign ORDER BY campaign.id ``` ### Response #### Success Response (200) - **GoogleAdsRow** (object) - Represents a campaign object populated with selected campaign and bidding strategy attributes. #### Response Example ```json { "campaign": { "id": "12345", "name": "Sample Campaign", "status": "ENABLED" }, "biddingStrategy": { "name": "Maximize Conversions" } } ``` ``` -------------------------------- ### Query campaign attributes Source: https://developers.google.com/google-ads/api/docs/query./google-ads/api/docs/query/overview This example demonstrates a basic Google Ads Query Language query to retrieve the ID, name, and status of campaigns. It orders the results by campaign ID. The output is a list of GoogleAdsRow objects, each containing campaign details. ```googleads-query SELECT campaign.id, campaign.name, campaign.status FROM campaign ORDER BY campaign.id ``` -------------------------------- ### Query campaign attributes with metrics Source: https://developers.google.com/google-ads/api/docs/query./google-ads/api/docs/query/overview This example shows how to query for campaign attributes along with metrics. It filters campaigns that are paused and have more than 1000 impressions, ordering the results by campaign ID. Each row will include campaign details and populated metrics. ```googleads-query SELECT campaign.id, campaign.name, campaign.status, metrics.impressions FROM campaign WHERE campaign.status = 'PAUSED' AND metrics.impressions > 1000 ORDER BY campaign.id ``` -------------------------------- ### Querying Segments Source: https://developers.google.com/google-ads/api/docs/query./google-ads/api/docs/query/overview This section demonstrates how to query for segments alongside selected attributes for a given resource. It shows how to filter and order results based on campaign status, impressions, and date segments. ```APIDOC ## SELECT Segments ### Description Queries for segments alongside selected attributes for a given resource, filtering and ordering results. ### Method SELECT ### Endpoint N/A (This is a query language example) ### Parameters #### Query Parameters - **segments.date** (string) - Optional - Segments data by date (e.g., `LAST_30_DAYS`). - **campaign.status** (string) - Optional - Filters campaigns by status (e.g., `PAUSED`). - **metrics.impressions** (integer) - Optional - Filters by the number of impressions. ### Request Example ```sql SELECT campaign.id, campaign.name, campaign.status, metrics.impressions, segments.date, FROM campaign WHERE campaign.status = 'PAUSED' AND metrics.impressions > 1000 AND segments.date during LAST_30_DAYS ORDER BY campaign.id ``` ### Response #### Success Response (200) - **GoogleAdsRow** (object) - Represents a tuple of a campaign and the date segment. #### Response Example ```json { "campaign": { "id": "12345", "name": "Sample Campaign", "status": "PAUSED" }, "metrics": { "impressions": "1500" }, "segments": { "date": "2023-10-27" } } ``` ``` -------------------------------- ### Mutate Based on Query Results Source: https://developers.google.com/google-ads/api/docs/query./google-ads/api/docs/query/overview This section outlines a workflow for modifying resources based on query results. It describes executing a query, retrieving resource objects, modifying them, and sending them back to the mutate method. ```APIDOC ## Mutate Based on Query Results ### Description Allows modification of resources based on query results. This involves querying, retrieving, modifying, and then mutating the resources. ### Workflow 1. Execute a query for resources meeting specific criteria. 2. Get the resource objects (e.g., `Campaign` object) from the response. 3. Modify the desired fields of the resource objects. 4. Call the appropriate service's `Mutate` method with the modified resources. ### Example Workflow Step (Conceptual) 1. **Query for PAUSED campaigns with > 1000 impressions**: ```sql SELECT campaign FROM campaign WHERE campaign.status = 'PAUSED' AND metrics.impressions > 1000 ``` 2. **Modify campaign status from PAUSED to ENABLED**: (Code would involve iterating through results and updating the `campaign.status` field) 3. **Call `CampaignService.MutateCampaigns` with modified campaigns**: (This step involves using the client library to send the updated campaign objects.) ``` -------------------------------- ### Querying Field Metadata Source: https://developers.google.com/google-ads/api/docs/query./google-ads/api/docs/query/overview This section describes how to query the `GoogleAdsFieldService` to retrieve field metadata. This information helps understand how fields can be used together in a query and allows for programmatic validation or building of queries. ```APIDOC ## SELECT Field Metadata ### Description Queries the `GoogleAdsFieldService` to retrieve metadata about fields, enabling understanding of field usage and programmatic query validation. ### Method SELECT ### Endpoint N/A (This is a query language example) ### Parameters #### Query Parameters - **name** (string) - Optional - The name of the resource or field to query metadata for (e.g., `customer`, `campaign.id`). - **category** (string) - Optional - The category of the field. - **selectable** (boolean) - Optional - Indicates if the field is selectable. - **filterable** (boolean) - Optional - Indicates if the field is filterable. - **sortable** (boolean) - Optional - Indicates if the field is sortable. - **selectable_with** (string) - Optional - Fields that can be selected with this field. - **data_type** (string) - Optional - The data type of the field. - **is_repeated** (boolean) - Optional - Indicates if the field is repeated. ### Request Example ```sql SELECT name, category, selectable, filterable, sortable, selectable_with, data_type, is_repeated WHERE name = "" ``` ### Response #### Success Response (200) - **GoogleAdsField** (object) - Contains metadata about a specific field or resource. #### Response Example ```json { "name": "campaign.id", "category": "RESOURCE", "selectable": true, "filterable": true, "sortable": true, "selectable_with": [ "campaign.name", "campaign.status" ], "data_type": "INT64", "is_repeated": false } ``` ``` -------------------------------- ### Query Campaign Attributes and Related Bidding Strategy Source: https://developers.google.com/google-ads/api/docs/query./google-ads/api/docs/query/overview This query selects attributes of a campaign, including its ID, name, status, and the name of its associated bidding strategy. It demonstrates how to join implicitly with attributed resources by selecting attributes from them. Each returned row contains campaign details along with the bidding strategy's name. ```googleads-query SELECT campaign.id, campaign.name, campaign.status, bidding_strategy.name FROM campaign ORDER BY campaign.id ``` -------------------------------- ### Query Google Ads Data Segments by Date Source: https://developers.google.com/google-ads/api/docs/query./google-ads/api/docs/query/overview This query retrieves campaign details, metrics, and segments data by date. It filters for paused campaigns with over 1000 impressions within the last 30 days. The results are ordered by campaign ID. This query segments the data by date, meaning each row represents a combination of a campaign and a specific date segment. ```googleads-query SELECT campaign.id, campaign.name, campaign.status, metrics.impressions, segments.date, FROM campaign WHERE campaign.status = 'PAUSED' AND metrics.impressions > 1000 AND segments.date during LAST_30_DAYS ORDER BY campaign.id ``` -------------------------------- ### Query Field Metadata from GoogleAdsFieldService Source: https://developers.google.com/google-ads/api/docs/query./google-ads/api/docs/query/overview This query retrieves metadata about fields available in the Google Ads API, such as name, category, data type, and sortability. It's used to understand how fields can be combined in queries and to validate or build queries programmatically. Replace '' with the desired resource or field name. ```googleads-query SELECT name, category, selectable, filterable, sortable, selectable_with, data_type, is_repeated WHERE name = "" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.