Campaign budget
A Local campaign cannot use a shared campaign budget. Make sure the campaign
budget you specify has
explicitly_shared
set to false
.
Perl
sub create_campaign_budget { my ($api_client, $customer_id) = @_; # Create a campaign budget. my $campaign_budget = Google::Ads::GoogleAds::V6::Resources::CampaignBudget->new({ name => "Interplanetary Cruise Budget #" . uniqid(), amountMicros => 50000000, deliveryMethod => STANDARD, # A Local campaign cannot use a shared campaign budget. explicitlyShared => "false" }); # Create a campaign budget operation. my $campaign_budget_operation = Google::Ads::GoogleAds::V6::Services::CampaignBudgetService::CampaignBudgetOperation ->new({ create => $campaign_budget }); # Issue a mutate request to add the campaign budget. my $campaign_budgets_response = $api_client->CampaignBudgetService()->mutate({ customerId => $customer_id, operations => [$campaign_budget_operation]}); my $campaign_budget_resource_name = $campaign_budgets_response->{results}[0]{resourceName}; printf "Created campaign budget with resource name: '%s'.\n", $campaign_budget_resource_name; return $campaign_budget_resource_name; }
Local campaign
To create a Local campaign, follow the steps in our code example with these specifics:
Set the
advertising_channel_type
toLOCAL
.Set the
advertising_channel_sub_type
toLOCAL_CAMPAIGN
.Set the
campaign_budget
to the resource name of the newly created campaign budget as above.Set the
maximize_conversion_value
to a newly createdMaximizeConversionValue
object. A ROAS target can be optionally set on thetarget_roas
field onMaximizeConversionValue
.Set the
local_campaign_setting
to anLocalCampaignSetting
object with:location_source_type
set to eitherGOOGLE_MY_BUSINESS
to use the locations in your linked Google My Business account, orAFFILIATE
to use the affiliate location extensions in your Google Ads account.
optimization_goal_setting
is required for Local campaigns. Select DRIVING_DIRECTIONS and/or CALL_CLICKS to optimize the actions in your campaign.
Perl
sub create_campaign { my ($api_client, $customer_id, $budget_resource_name) = @_; # Create a campaign. my $campaign = Google::Ads::GoogleAds::V6::Resources::Campaign->new({ name => "Interplanetary Cruise Local #" . uniqid(), campaignBudget => $budget_resource_name, # Recommendation: Set the campaign to PAUSED when creating it to prevent # the ads from immediately serving. Set to ENABLED once you've added # targeting and the ads are ready to serve. status => PAUSED, # All Local campaigns have an advertisingChannelType of LOCAL and # advertisingChannelSubType of LOCAL_CAMPAIGN. advertisingChannelType => LOCAL, advertisingChannelSubType => LOCAL_CAMPAIGN, # Bidding strategy must be set directly on the campaign. # Setting a portfolio bidding strategy by resource name is not supported. # Maximize conversion value is the only strategy supported for Local # campaigns. An optional ROAS (Return on Advertising Spend) can be set for # MaximizeConversionValue. The ROAS value must be specified as a ratio in the # API. It is calculated by dividing "total value" by "total spend". # For more information on maximize conversion value, see the support article: # http://support.google.com/google-ads/answer/7684216. maximizeConversionValue => Google::Ads::GoogleAds::V6::Common::MaximizeConversionValue->new( {targetRoas => 3.5} ), # Configure the Local campaign setting. localCampaignSetting => Google::Ads::GoogleAds::V6::Resources::LocalCampaignSetting->new({ # Use the locations associated with the customer's linked Google # My Business account. locationSourceType => GOOGLE_MY_BUSINESS } ), # Optimization goal setting is mandatory for Local campaigns. This example # selects driving directions and call clicks as goals. optimizationGoalSetting => Google::Ads::GoogleAds::V6::Resources::OptimizationGoalSetting->new({ optimizationGoalTypes => [CALL_CLICKS, DRIVING_DIRECTIONS]})}); # Create a campaign operation. my $campaign_operation = Google::Ads::GoogleAds::V6::Services::CampaignService::CampaignOperation-> new({ create => $campaign }); # Issue a mutate request to add the campaign. my $campaigns_response = $api_client->CampaignService()->mutate({ customerId => $customer_id, operations => [$campaign_operation]}); my $campaign_resource_name = $campaigns_response->{results}[0]{resourceName}; printf "Created Local campaign with resource name: '%s'.\n", $campaign_resource_name; return $campaign_resource_name; }