Page Summary
-
Smart campaigns are limited to a single ad group.
-
The ad group type for a Smart campaign must be set to
AdGroupTypeEnum.SMART_CAMPAIGN_ADS. -
A Smart campaign ad group can contain multiple ads, with headlines and descriptions potentially combined dynamically.
-
Smart campaign ads must have their type set to
AdTypeEnum.SMART_CAMPAIGN_AD. -
Smart campaign ads can have a maximum of three headlines and two descriptions.
This document explains how to create an ad group, and an ad that belongs to an ad group.
Create an ad group
Similar to the Campaign created in previous steps,
this ad group requires minimal configuration because it is optimized
automatically.
Key requirements for Smart campaign ad groups:
- A Smart campaign can have only one ad group.
- The
typemust be set toAdGroupTypeEnum.SMART_CAMPAIGN_ADS.
This example sets the campaign field to the
temporary resource name
used to create a campaign in earlier steps.
Java
private MutateOperation createAdGroupOperation(long customerId) { MutateOperation.Builder builder = MutateOperation.newBuilder(); builder .getAdGroupOperationBuilder() .getCreateBuilder() .setResourceName(ResourceNames.adGroup(customerId, AD_GROUP_TEMPORARY_ID)) .setName("Smart campaign ad group " + CodeSampleHelper.getShortPrintableDateTime()) .setCampaign(ResourceNames.campaign(customerId, SMART_CAMPAIGN_TEMPORARY_ID)) .setType(AdGroupType.SMART_CAMPAIGN_ADS); return builder.build(); }
C#
/// <summary> /// Creates a MutateOperation that creates a new ad group. /// A temporary ID will be used in the campaign resource name for this ad group to /// associate it with the Smart campaign created in earlier steps. A temporary ID will /// also be used for its own resource name so that we can associate an ad group ad with /// it later in the process. /// Only one ad group can be created for a given Smart campaign. /// </summary> /// <param name="customerId">The Google Ads customer ID.</param> /// <returns>A MutateOperation that creates a new ad group.</returns> private MutateOperation CreateAdGroupOperation(long customerId) { return new MutateOperation { AdGroupOperation = new AdGroupOperation { Create = new AdGroup { // Set the ad group ID to a temporary ID. ResourceName = ResourceNames.AdGroup(customerId, AD_GROUP_TEMPORARY_ID), Name = $"Smart campaign ad group #{ExampleUtilities.GetRandomString()}", // Set the campaign ID to a temporary ID. Campaign = ResourceNames.Campaign(customerId, SMART_CAMPAIGN_TEMPORARY_ID), // The ad group type must be SmartCampaignAds. Type = AdGroupType.SmartCampaignAds } } }; }
PHP
private static function createAdGroupOperation(int $customerId): MutateOperation { // Creates the ad group object. $adGroup = new AdGroup([ // Sets the ad group ID to a temporary ID. 'resource_name' => ResourceNames::forAdGroup($customerId, self::AD_GROUP_TEMPORARY_ID), 'name' => "Smart campaign ad group #" . Helper::getPrintableDatetime(), // Sets the campaign ID to a temporary ID. 'campaign' => ResourceNames::forCampaign($customerId, self::SMART_CAMPAIGN_TEMPORARY_ID), // The ad group type must be set to SMART_CAMPAIGN_ADS. 'type' => AdGroupType::SMART_CAMPAIGN_ADS ]); // Creates the MutateOperation that creates the ad group. return new MutateOperation([ 'ad_group_operation' => new AdGroupOperation(['create' => $adGroup]) ]); }