Resource names

  • The ResourceNames utility constructs entity resource names from relevant IDs.

  • To get a campaign resource name, you need the customer ID and campaign ID.

  • Different entities require different sets of IDs to form their resource names.

The ResourceNames utility lets you construct the resource name of an entity when you know all of the relevant IDs related to that entity. For example, a campaign resource name is in the format customers/<CUSTOMER_ID>/campaigns/<CAMPAIGN_ID>, so if you know the customer ID and the campaign ID, you can use the ResourceNames utility to construct the full resource name.

Basic example

If $customerId contains your customer ID and $campaignId contains your campaign ID, you can call ResourceNames::forCampaign() to build the resource name of the campaign as shown in the following example:

use Google\Ads\GoogleAds\Util\V25\ResourceNames;

$customerId = 1234567890;
$campaignId = 9876543210;

$campaignResourceName = ResourceNames::forCampaign($customerId, $campaignId);

Entities with multiple IDs

Each entity has a specific set of IDs that composes its resource name. For example, the resource name of an ad group criterion requires a customer ID, ad group ID, and criterion ID:

use Google\Ads\GoogleAds\Util\V25\ResourceNames;

$adGroupCriterionResourceName = ResourceNames::forAdGroupCriterion(
    $customerId,
    $adGroupId,
    $criterionId
);