You can group campaigns and set shared performance targets. This feature allows you to easily monitor and forecast a campaign group's overall performance. This guide covers how to work with campaign groups.
Establish a campaign group
The first step is to create a campaign group so you can track the overall performance of multiple campaigns. This is done as follows:
C#
private static CampaignGroup CreateCampaignGroup(AdWordsUser user) { using (CampaignGroupService campaignGroupService = (CampaignGroupService) user.GetService(AdWordsService.v201809.CampaignGroupService)) { // Create the campaign group. CampaignGroup campaignGroup = new CampaignGroup { name = "Mars campaign group - " + ExampleUtilities.GetShortRandomString() }; // Create the operation. CampaignGroupOperation operation = new CampaignGroupOperation { operand = campaignGroup, @operator = Operator.ADD }; try { CampaignGroupReturnValue retval = campaignGroupService.mutate( new CampaignGroupOperation[] { operation }); // Display the results. CampaignGroup newCampaignGroup = retval.value[0]; Console.WriteLine( "Campaign group with ID = '{0}' and name = '{1}' was created.", newCampaignGroup.id, newCampaignGroup.name); return newCampaignGroup; } catch (Exception e) { throw new System.ApplicationException("Failed to add campaign group.", e); } } }
Java
private static CampaignGroup createCampaignGroup( AdWordsServicesInterface adWordsServices, AdWordsSession session) throws RemoteException { // Get the CampaignGroupService. CampaignGroupServiceInterface campaignGroupService = adWordsServices.get(session, CampaignGroupServiceInterface.class); // Create the campaign group. CampaignGroup campaignGroup = new CampaignGroup(); campaignGroup.setName("Mars campaign group #" + System.currentTimeMillis()); // Create the operation. CampaignGroupOperation operation = new CampaignGroupOperation(); operation.setOperand(campaignGroup); operation.setOperator(Operator.ADD); CampaignGroup newCampaignGroup = campaignGroupService.mutate(new CampaignGroupOperation[] {operation}).getValue(0); System.out.printf( "Campaign group with ID %d and name '%s' was created.%n", newCampaignGroup.getId(), newCampaignGroup.getName()); return newCampaignGroup; }
Python
# Get the CampaignGroupService. campaign_group_service = client.GetService('CampaignGroupService', version='v201809') # Create the operation. operations = [{ 'operator': 'ADD', # Create the campaign group. 'operand': { 'name': 'Mars campaign group #%d' % uuid.uuid4() } }] campaign_group = campaign_group_service.mutate(operations)['value'][0] campaign_group_id = campaign_group['id'] # Display the results. print('Campaign group with ID "%d" and name "%s" was created.' % ( campaign_group_id, campaign_group['name']))
PHP
private static function createCampaignGroup( AdWordsServices $adWordsServices, AdWordsSession $session ) { $campaignGroupService = $adWordsServices->get($session, CampaignGroupService::class); // Create the campaign group. $campaignGroup = new CampaignGroup(); $campaignGroup->setName('Mars campaign group #' . uniqid()); // Create the operation. $operation = new CampaignGroupOperation(); $operation->setOperand($campaignGroup); $operation->setOperator(Operator::ADD); $campaignGroup = $campaignGroupService->mutate([$operation])->getValue()[0]; printf( "Campaign group with ID %d and name '%s' was created.\n", $campaignGroup->getId(), $campaignGroup->getName() ); return $campaignGroup; }
Perl
sub _create_campaign_group { my ($client) = @_; # Create the campaign group. my $campaign_group = Google::Ads::AdWords::v201809::CampaignGroup->new({ name => sprintf("Mars campaign group - #%s", uniqid()), }); # Create the operation. my $operation = Google::Ads::AdWords::v201809::CampaignGroupOperation->new({ operator => "ADD", operand => $campaign_group }); my $result = $client->CampaignGroupService()->mutate({operations => [$operation]}); $campaign_group = $result->get_value()->[0]; printf( "Campaign group with ID %d and name '%s' was created.\n", $campaign_group->get_id(), $campaign_group->get_name()); return $campaign_group; }
Ruby
def create_campaign_group(adwords) campaign_group_srv = adwords.service(:CampaignGroupService, API_VERSION) campaign_group = { :name => "Mars campaign group #%d" % (Time.new.to_f * 1000).to_i } operation = { :operand => campaign_group, :operator => 'ADD' } new_campaign_group = campaign_group_srv.mutate([operation])[:value].first puts "Campaign group with ID %d and name '%s' was created." % [ new_campaign_group[:id], new_campaign_group[:name] ] return new_campaign_group end
Next, add the campaigns you wish to track to this campaign group by setting the
campaign's campaignGroupId
field. You can pick any
combinations of Search, Shopping, Display, or Video campaigns, subject to the
following restrictions:
- Each campaign can only belong to one campaign group at a time.
- You can't add campaigns with shared budgets to a campaign group.
C#
private static void AddCampaignsToGroup(AdWordsUser user, long campaignGroupId, long[] campaignIds) { using (CampaignService campaignService = (CampaignService) user.GetService(AdWordsService.v201809.CampaignService)) { List<CampaignOperation> operations = new List<CampaignOperation>(); for (int i = 0; i < campaignIds.Length; i++) { Campaign campaign = new Campaign { id = campaignIds[i], campaignGroupId = campaignGroupId }; CampaignOperation operation = new CampaignOperation { operand = campaign, @operator = Operator.SET }; operations.Add(operation); } try { CampaignReturnValue retval = campaignService.mutate(operations.ToArray()); List<long> updatedCampaignIds = new List<long>(); retval.value.ToList().ForEach(updatedCampaign => updatedCampaignIds.Add(updatedCampaign.id)); // Display the results. Console.WriteLine( "The following campaign IDs were added to the campaign group " + "with ID '{0}':\n\t{1}'", campaignGroupId, string.Join(", ", updatedCampaignIds)); } catch (Exception e) { throw new System.ApplicationException( "Failed to add campaigns to campaign group.", e); } } }
Java
private static void addCampaignsToGroup( AdWordsServicesInterface adWordsServices, AdWordsSession session, CampaignGroup campaignGroup, List<Long> campaignIds) throws ApiException, RemoteException { // Get the CampaignService. CampaignServiceInterface campaignService = adWordsServices.get(session, CampaignServiceInterface.class); List<CampaignOperation> operations = new ArrayList<>(); for (Long campaignId : campaignIds) { Campaign campaign = new Campaign(); campaign.setId(campaignId); campaign.setCampaignGroupId(campaignGroup.getId()); CampaignOperation operation = new CampaignOperation(); operation.setOperand(campaign); operation.setOperator(Operator.SET); operations.add(operation); } CampaignReturnValue returnValue = campaignService.mutate(operations.toArray(new CampaignOperation[operations.size()])); System.out.printf( "The following campaign IDs were added to the campaign group with ID %d:%n", campaignGroup.getId()); for (Campaign campaign : returnValue.getValue()) { System.out.printf("\t%d%n", campaign.getId()); } }
Python
# Get the CampaignService. campaign_service = client.GetService('CampaignService', version='v201809') # Create the operations. operations = [{ 'operator': 'SET', 'operand': { 'id': campaign_id, 'campaignGroupId': campaign_group_id } } for campaign_id in campaign_ids] campaign_service.mutate(operations) # Display the results. print('The following campaign IDs were added to the campaign group with ID ' '"%d":\n\t%s' % (campaign_group_id, campaign_ids))
PHP
private static function addCampaignsToGroup( AdWordsServices $adWordsServices, AdWordsSession $session, $campaignGroup, $campaignIds ) { $campaignService = $adWordsServices->get($session, CampaignService::class); $operations = []; foreach ($campaignIds as $campaignId) { $campaign = new Campaign(); $campaign->setId($campaignId); $campaign->setCampaignGroupId($campaignGroup->getId()); $operation = new CampaignOperation(); $operation->setOperand($campaign); $operation->setOperator(Operator::SET); $operations[] = $operation; } $campaigns = $campaignService->mutate($operations)->getValue(); printf( "The following campaign IDs were added to the campaign group with ID %d:\n", $campaignGroup->getId() ); foreach ($campaigns as $campaign) { printf("\t%d\n", $campaign->getId()); } }
Perl
sub _add_campaigns_to_group { my ($client, $campaign_group_id, $campaign_ids) = @_; my @operations = (); foreach my $campaign_id (@{$campaign_ids}) { my $campaign = Google::Ads::AdWords::v201809::Campaign->new({ id => $campaign_id, campaignGroupId => $campaign_group_id }); # Create operation. my $campaign_operation = Google::Ads::AdWords::v201809::CampaignOperation->new({ operator => "SET", operand => $campaign }); push @operations, $campaign_operation; } # Add campaigns. my $result = $client->CampaignService()->mutate({operations => \@operations}); # Display campaigns. foreach my $campaign (@{$result->get_value()}) { printf "Campaign with ID %d was added to campaign group with ID %d.\n", $campaign->get_id(), $campaign->get_campaignGroupId(); } }
Ruby
def add_campaigns_to_group(adwords, campaign_group, campaign_ids) campaign_srv = adwords.service(:CampaignService, API_VERSION) operations = campaign_ids.map do |campaign_id| { :operand => { :id => campaign_id, :campaign_group_id => campaign_group[:id] }, :operator => 'SET' } end return_value = campaign_srv.mutate(operations) puts ("The following campaign IDs were added to the campaign group with " + " ID %d:") % campaign_group[:id] return_value[:value].each do |campaign| puts "\t%d" % campaign[:id] end end
Create performance targets
After creating the campaign group, you can add one or more performance targets to it. Once you set your performance targets, Google Ads can estimate whether you're on track to meet your goals. If it looks like you won't reach the targets you set, you can consider adjusting your campaign's settings to improve performance.
The code snippet below shows how to create a performance target.
C#
private static CampaignGroupPerformanceTarget CreatePerformanceTarget(AdWordsUser user, long campaignGroupId) { using (CampaignGroupPerformanceTargetService campaignGroupPerformanceTargetService = (CampaignGroupPerformanceTargetService) user.GetService(AdWordsService.v201809 .CampaignGroupPerformanceTargetService)) { // Create the performance target. CampaignGroupPerformanceTarget campaignGroupPerformanceTarget = new CampaignGroupPerformanceTarget { campaignGroupId = campaignGroupId }; PerformanceTarget performanceTarget = new PerformanceTarget { // Keep the CPC for the campaigns < $3. efficiencyTargetType = EfficiencyTargetType.CPC_LESS_THAN_OR_EQUAL_TO, efficiencyTargetValue = 3000000, // Keep the maximum spend under $50. spendTargetType = SpendTargetType.MAXIMUM }; Money maxSpend = new Money { microAmount = 500000000 }; performanceTarget.spendTarget = maxSpend; // Aim for at least 3000 clicks. performanceTarget.volumeTargetValue = 3000; performanceTarget.volumeGoalType = VolumeGoalType.MAXIMIZE_CLICKS; // Start the performance target today, and run it for the next 90 days. System.DateTime startDate = System.DateTime.Now; System.DateTime endDate = startDate.AddDays(90); performanceTarget.startDate = startDate.ToString("yyyyMMdd"); performanceTarget.endDate = endDate.ToString("yyyyMMdd"); campaignGroupPerformanceTarget.performanceTarget = performanceTarget; // Create the operation. CampaignGroupPerformanceTargetOperation operation = new CampaignGroupPerformanceTargetOperation { operand = campaignGroupPerformanceTarget, @operator = Operator.ADD }; try { CampaignGroupPerformanceTargetReturnValue retval = campaignGroupPerformanceTargetService.mutate( new CampaignGroupPerformanceTargetOperation[] { operation }); // Display the results. CampaignGroupPerformanceTarget newCampaignPerfTarget = retval.value[0]; Console.WriteLine( "Campaign performance target with id = '{0}' was added for " + "campaign group ID '{1}'.", newCampaignPerfTarget.id, newCampaignPerfTarget.campaignGroupId); return newCampaignPerfTarget; } catch (Exception e) { throw new System.ApplicationException( "Failed to create campaign performance target.", e); } } }
Java
private static void createPerformanceTarget( AdWordsServicesInterface adWordsServices, AdWordsSession session, CampaignGroup campaignGroup) throws ApiException, RemoteException { // Get the CampaignGroupPerformanceTargetService. CampaignGroupPerformanceTargetServiceInterface campaignGroupPerformanceTargetService = adWordsServices.get(session, CampaignGroupPerformanceTargetServiceInterface.class); // Create the performance target. CampaignGroupPerformanceTarget campaignGroupPerformanceTarget = new CampaignGroupPerformanceTarget(); campaignGroupPerformanceTarget.setCampaignGroupId(campaignGroup.getId()); PerformanceTarget performanceTarget = new PerformanceTarget(); // Keep the CPC for the campaigns < $3. performanceTarget.setEfficiencyTargetType(EfficiencyTargetType.CPC_LESS_THAN_OR_EQUAL_TO); performanceTarget.setEfficiencyTargetValue(3000000d); // Keep the maximum spend under $50. performanceTarget.setSpendTargetType(SpendTargetType.MAXIMUM); Money maxSpend = new Money(); maxSpend.setMicroAmount(500000000L); performanceTarget.setSpendTarget(maxSpend); // Aim for at least 3000 clicks. performanceTarget.setVolumeTargetValue(3000L); performanceTarget.setVolumeGoalType(VolumeGoalType.MAXIMIZE_CLICKS); // Start the performance target today, and run it for the next 90 days. DateTime startDate = DateTime.now(); DateTime endDate = DateTime.now().plusDays(90); performanceTarget.setStartDate(startDate.toString("yyyyMMdd")); performanceTarget.setEndDate(endDate.toString("yyyyMMdd")); campaignGroupPerformanceTarget.setPerformanceTarget(performanceTarget); // Create the operation. CampaignGroupPerformanceTargetOperation operation = new CampaignGroupPerformanceTargetOperation(); operation.setOperand(campaignGroupPerformanceTarget); operation.setOperator(Operator.ADD); CampaignGroupPerformanceTarget newCampaignGroupPerformanceTarget = campaignGroupPerformanceTargetService .mutate(new CampaignGroupPerformanceTargetOperation[] {operation}) .getValue(0); // Display the results. System.out.printf( "Campaign group performance target with ID %d was added for campaign group ID %d.%n", newCampaignGroupPerformanceTarget.getId(), newCampaignGroupPerformanceTarget.getCampaignGroupId()); }
Python
# Get the CampaignGroupPerformanceTargetService. cgpt_service = client.GetService('CampaignGroupPerformanceTargetService', version='v201809') # Create the operation. operations = [{ 'operator': 'ADD', # Create the performance target. 'operand': { 'campaignGroupId': campaign_group_id, 'performanceTarget': { # Keep the CPC for the campaigns < $3. 'efficiencyTargetType': 'CPC_LESS_THAN_OR_EQUAL_TO', 'efficiencyTargetValue': 3000000, # Keep the maximum spend under $50. 'spendTargetType': 'MAXIMUM', 'spendTarget': { 'microAmount': 500000000 }, # Aim for at least 3000 clicks. 'volumeGoalType': 'MAXIMIZE_CLICKS', 'volumeTargetValue': 3000, # Start the performance target today, and run it for the next 90 # days. 'startDate': datetime.datetime.now().strftime('%Y%m%d'), 'endDate': (datetime.datetime.now() + datetime.timedelta(90)).strftime('%Y%m%d') } } }] cgpt = cgpt_service.mutate(operations)['value'][0] # Display the results. print('Campaign performance target with ID "%d" was added for campaign ' 'group ID "%d".' % (cgpt['id'], cgpt['campaignGroupId']))
PHP
private static function createPerformanceTarget( AdWordsServices $adWordsServices, AdWordsSession $session, CampaignGroup $campaignGroup ) { $campaignGroupPerformanceTargetService = $adWordsServices->get( $session, CampaignGroupPerformanceTargetService::class ); // Create the performance target. $performanceTarget = new PerformanceTarget(); // Keep the CPC for the campaigns < $3. $performanceTarget->setEfficiencyTargetType( EfficiencyTargetType::CPC_LESS_THAN_OR_EQUAL_TO ); $performanceTarget->setEfficiencyTargetValue(3000000); // Keep the maximum spend under $50. $performanceTarget->setSpendTargetType(SpendTargetType::MAXIMUM); $maxSpend = new Money(); $maxSpend->setMicroAmount(500000000); $performanceTarget->setSpendTarget($maxSpend); // Aim for at least 3000 clicks. $performanceTarget->setVolumeTargetValue(3000); $performanceTarget->setVolumeGoalType(VolumeGoalType::MAXIMIZE_CLICKS); // Start the performance target today, and run it for the next 90 days. $startDate = date('Ymd', strtotime('now')); $endDate = date('Ymd', strtotime('+90 day')); $performanceTarget->setStartDate($startDate); $performanceTarget->setEndDate($endDate); // Create the campaign group performance target. $campaignGroupPerformanceTarget = new CampaignGroupPerformanceTarget(); $campaignGroupPerformanceTarget->setCampaignGroupId( $campaignGroup->getId() ); $campaignGroupPerformanceTarget->setPerformanceTarget($performanceTarget); // Create the operation. $operation = new CampaignGroupPerformanceTargetOperation(); $operation->setOperand($campaignGroupPerformanceTarget); $operation->setOperator(Operator::ADD); $campaignGroupPerformanceTarget = $campaignGroupPerformanceTargetService->mutate([$operation])->getValue()[0]; // Display the results. printf( "Campaign group performance target with ID %d was added for campaign group ID %d.\n", $campaignGroupPerformanceTarget->getId(), $campaignGroupPerformanceTarget->getCampaignGroupId() ); }
Perl
sub _create_performance_target { my ($client, $campaign_group_id) = @_; # Start the performance target today, and run it for the next 90 days. my (undef, undef, undef, $mday, $mon, $year) = localtime(time); my $start_date = sprintf("%d%02d%02d", ($year + 1900), ($mon + 1), $mday); (undef, undef, undef, $mday, $mon, $year) = localtime(time + 60 * 60 * 24 * 90); my $end_date = sprintf("%d%02d%02d", ($year + 1900), ($mon + 1), $mday); my $performance_target = Google::Ads::AdWords::v201809::PerformanceTarget->new({ # Keep the CPC for the campaigns < $3. efficiencyTargetType => "CPC_LESS_THAN_OR_EQUAL_TO", efficiencyTargetValue => 3000000, # Keep the maximum spend under $50. spendTargetType => "MAXIMUM", spendTarget => Google::Ads::AdWords::v201809::Money->new({microAmount => 500000000}), # Aim for at least 3000 clicks. volumeTargetValue => 3000, volumeGoalType => "MAXIMIZE_CLICKS", startDate => $start_date, endDate => $end_date }); # Create the performance target. my $campaign_group_performance_target = Google::Ads::AdWords::v201809::CampaignGroupPerformanceTarget->new({ campaignGroupId => $campaign_group_id, performanceTarget => $performance_target }); # Create the operation. my $operation = Google::Ads::AdWords::v201809::CampaignGroupPerformanceTargetOperation->new( { operator => "ADD", operand => $campaign_group_performance_target }); my $result = $client->CampaignGroupPerformanceTargetService() ->mutate({operations => [$operation]}); $campaign_group_performance_target = $result->get_value()->[0]; printf( "Campaign performance target with ID %d was added for campaign group ID " . "%d.\n", $campaign_group_performance_target->get_id(), $campaign_group_performance_target->get_campaignGroupId()); }
Ruby
def create_performance_target(adwords, campaign_group) campaign_group_performance_target_srv = adwords.service( :CampaignGroupPerformanceTargetService, API_VERSION) campaign_group_performance_target = { :campaign_group_id => campaign_group[:id], :performance_target => { # Keep the CPC for the campaigns <=$3. :efficiency_target_type => 'CPC_LESS_THAN_OR_EQUAL_TO', :efficiency_target_value => 3_000_000, # Keep the maximum spend under $50. :spend_target_type => 'MAXIMUM', :spend_target => { :micro_amount => 50_000_000 }, # Aim for at least 3000 clicks. :volume_target_value => 3000, :volume_goal_type => 'MAXIMIZE_CLICKS', # Start the performance target today, and run it for the next 90 days. :start_date => DateTime.parse((Date.today).to_s).strftime('%Y%m%d'), :end_date => DateTime.parse((Date.today + 90).to_s).strftime('%Y%m%d') } } operation = { :operand => campaign_group_performance_target, :operator => 'ADD' } new_campaign_group_performance_target = campaign_group_performance_target_srv.mutate([operation])[:value].first puts ("Campaign group performance target with ID %s was added for campaign " + "group ID %d") % [new_campaign_group_performance_target[:id], new_campaign_group_performance_target[:campaign_group_id]] end
Performance targets can focus on either clicks or conversions and have the following dimensions:
- Volume: This dimension is used to specify how the progress of the goal should be reported.
volumeGoalType
specifies whether to use clicks or conversions, andvolumeTargetValue
specifies the goal you intend to reach within the specified time period. - Efficiency target: This dimension puts an optional constraint on the
volume goal of the performance target, usually in terms of spending.
efficiencyTargetType
specifies the metric to track for efficiency andefficiencyTargetValue
specifies the intended value for the efficiency target. - Spend target: This dimension puts an optional constraint on how much
money you are willing to spend during the time period of the performance target.
spendTarget
specifies the amount in micro units of the customer's currency andspendTargetType
specifies whether this is a minimum or maximum amount. - Time period: If you specify either an efficiency target or a spend
target, you also need to specify the time period (
startDate
andendDate
) to track the targets.
Tracking performance
You can track the performance of your campaign group using the
CAMPAIGN_GROUP_PERFORMANCE_REPORT
.
You can also check the forecastStatus
field of individual performance targets to see how they are performing. If
forecastStatus
returns ACTIVE_NEEDS_ATTENTION
, your campaigns are likely to
miss their targets and you should review them to improve performance.
Code examples
Complete code examples for working with campaign groups and performance targets are available in each client library: