Google-Ads-GoogleAds-Client
view release on metacpan or search on metacpan
examples/advanced_operations/add_performance_max_campaign.pl view on Meta::CPAN
return $operations;
}
# [END create_and_link_brand_assets]
# Creates a list of MutateOperations that create asset group signals.
# [START add_performance_max_campaign_9]
sub create_asset_group_signal_operations {
my ($customer_id, $audience_id) = @_;
my $operations = [];
return $operations if not defined $audience_id;
push @$operations,
Google::Ads::GoogleAds::V24::Services::GoogleAdsService::MutateOperation->
new({
assetGroupSignalOperation =>
Google::Ads::GoogleAds::V24::Services::AssetGroupSignalService::AssetGroupSignalOperation
->new({
# To learn more about Audience Signals, see:
# https://developers.google.com/google-ads/api/docs/performance-max/asset-groups#audience_signals
create =>
Google::Ads::GoogleAds::V24::Resources::AssetGroupSignal->new({
assetGroup =>
Google::Ads::GoogleAds::V24::Utils::ResourceNames::asset_group(
$customer_id, ASSET_GROUP_TEMPORARY_ID
),
audience =>
Google::Ads::GoogleAds::V24::Common::AudienceInfo->new({
audience =>
Google::Ads::GoogleAds::V24::Utils::ResourceNames::audience(
$customer_id, $audience_id
)})})})});
return $operations;
}
# [END add_performance_max_campaign_9]
# Prints the details of a MutateGoogleAdsResponse.
# Parses the "response" oneof field name and uses it to extract the new entity's
# name and resource name.
sub print_response_details {
my ($mutate_google_ads_response) = @_;
foreach
my $response (@{$mutate_google_ads_response->{mutateOperationResponses}})
{
my $result_type = [keys %$response]->[0];
printf "Created a(n) %s with '%s'.\n",
ucfirst $result_type =~ s/Result$//r,
$response->{$result_type}{resourceName};
}
}
# [END add_performance_max_campaign]
# Don't run the example if the file is being included.
if (abs_path($0) ne abs_path(__FILE__)) {
return 1;
}
# Get Google Ads Client, credentials will be read from ~/googleads.properties.
my $api_client = Google::Ads::GoogleAds::Client->new();
# By default examples are set to die on any server returned fault.
$api_client->set_die_on_faults(1);
my $customer_id = undef;
my $audience_id = undef;
my $brand_guidelines_enabled = "true";
# Parameters passed on the command line will override any parameters set in code.
GetOptions(
"customer_id=s" => \$customer_id,
"audience_id=i" => \$audience_id,
"brand_guidelines_enabled=s" => \$brand_guidelines_enabled
);
# Print the help message if the parameters are not initialized in the code nor
# in the command line.
pod2usage(2) if not check_params($customer_id);
# Call the example.
add_performance_max_campaign(
$api_client, $customer_id =~ s/-//gr,
$audience_id, $brand_guidelines_enabled
);
=pod
=head1 NAME
add_performance_max_campaign
=head1 DESCRIPTION
This example shows how to create a Performance Max campaign.
For more information about Performance Max campaigns, see
https://developers.google.com/google-ads/api/docs/performance-max/overview.
Prerequisites:
- You must have at least one conversion action in the account. For
more about conversion actions, see
https://developers.google.com/google-ads/api/docs/conversions/overview#conversion_actions.
This example uses the default customer conversion goals. For an example of
setting campaign-specific conversion goals, see
shopping_ads/add_performance_max_retail_campaign.pl.
=head1 SYNOPSIS
add_performance_max_campaign.pl [options]
-help Show the help message.
-customer_id The Google Ads customer ID.
-audience_id [optional] An audience ID to use to improve the
targeting of the Performance Max campaign.
-brand_guidelines_enabled [optional] A boolean value indicating if the campaign is enabled for brand guidelines. Defaults to false.
=cut
( run in 0.577 second using v1.01-cache-2.11-cpan-f56aa216473 )