GOOGLE-ADWORDS-PERL-CLIENT
view release on metacpan or search on metacpan
examples/v201309/basic_operations/add_campaigns.pl view on Meta::CPAN
targetGoogleSearch => 1,
targetSearchNetwork => 1,
targetContentNetwork => 1,
targetPartnerSearchNetwork => 0
}),
# Frecuency cap (non-required).
frequencyCap => Google::Ads::AdWords::v201309::FrequencyCap->new({
impressions => 5,
timeUnit => "DAY",
level => "ADGROUP"
}),
settings => [
# Advanced location targeting settings (non-required).
Google::Ads::AdWords::v201309::GeoTargetTypeSetting->new({
positiveGeoTargetType => "DONT_CARE",
negativeGeoTargetType => "DONT_CARE"
}),
# Keyword match setting (non-required).
Google::Ads::AdWords::v201309::KeywordMatchSetting->new({
optIn => 0
})
],
# Additional properties (non-required).
startDate => $today,
endDate => $tomorrow,
status => "PAUSED",
adServingOptimizationStatus => "ROTATE"
});
# Create operation.
my $campaign_operation =
Google::Ads::AdWords::v201309::CampaignOperation->new({
operator => "ADD",
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 name \"%s\" and id \"%s\" was added.\n",
$campaign->get_name(), $campaign->get_id();
}
return 1;
}
# Don't run the example if the file is being included.
if (abs_path($0) ne abs_path(__FILE__)) {
return 1;
}
# Log SOAP XML request, response and API errors.
Google::Ads::AdWords::Logging::enable_all_logging();
# Get AdWords Client, credentials will be read from ~/adwords.properties.
my $client = Google::Ads::AdWords::Client->new({version => "v201309"});
# By default examples are set to die on any server returned fault.
$client->set_die_on_faults(1);
# Call the example
add_campaigns($client);
( run in 0.685 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )