Create an Ad Group

To create an ad group for your Smart Display campaign, follow the same process you use for other ad groups. However, since Google Ads manages most aspects of a Smart Display campaign, targeting options at the ad group level are not allowed.


private static function createAdGroup(
    GoogleAdsClient $googleAdsClient,
    int $customerId,
    string $campaignResourceName
) {
    // Constructs an ad group and set its type.
    $adGroup = new AdGroup([
        'name' => 'Earth to Mars Cruises #' . uniqid(),
        'campaign' => $campaignResourceName,
        'status' => AdGroupStatus::PAUSED,

    // Creates an ad group operation.
    $adGroupOperation = new AdGroupOperation();

    // Issues a mutate request to add the ad group.
    $adGroupServiceClient = $googleAdsClient->getAdGroupServiceClient();
    /** @var MutateAdGroupsResponse $adGroupResponse */
    $adGroupResponse = $adGroupServiceClient->mutateAdGroups($customerId, [$adGroupOperation]);

    // Print out some information about the added ad group.
    $adGroupResourceName = $adGroupResponse->getResults()[0]->getResourceName();
    printf("Added ad group named '%s'.%s", $adGroupResourceName, PHP_EOL);

    return $adGroupResourceName;