Page Summary
-
A resource name is a unique identifier for an entity in the Google Ads API, formatted as a string.
-
The PathLookupUtil can construct a resource name if you know all the relevant IDs for that entity.
-
Resource names for different entities require different sets of IDs to be constructed using the PathLookupUtil.
The unique identifier for an entity in the Google Ads API is called a resource name,
and is represented as a string with a predictable format. If you know the
constituent components of a resource name, you can use PathLookupUtil to
generate the final resource name.
PathLookupUtil
The PathLookupUtil utility constructs the resource name of an entity when you
provide all of the relevant IDs related to that entity. For example, a campaign
resource name uses the format customers/{customer_id}/campaigns/{campaign_id},
so if you know the customer ID and the campaign ID, you can use client.path to
construct the full resource name:
require 'google/ads/google_ads'
client = Google::Ads::GoogleAds::GoogleAdsClient.new
customer_id = '1234567890'
campaign_id = '9876543210'
# Generates: "customers/1234567890/campaigns/9876543210"
campaign_resource_name = client.path.campaign(customer_id, campaign_id)
Supported entities
You can use other entity names on client.path as well, which accept different
IDs depending on the hierarchy of the resource name:
- Campaign:
client.path.campaign(customer_id, campaign_id) - Ad group:
client.path.ad_group(customer_id, ad_group_id) - Ad group ad:
client.path.ad_group_ad(customer_id, ad_group_id, ad_id)