Google-Ads-AdWords-Client
view release on metacpan or search on metacpan
examples/v201809/advanced_operations/upload_offline_conversions.pl view on Meta::CPAN
$conversion_tracker->get_name(),
$conversion_tracker->get_id();
}
} else {
print "No upload conversions were added.\n";
return;
}
# Associate offline conversions with the upload conversion we created.
my $feed = Google::Ads::AdWords::v201809::OfflineConversionFeed->new({
conversionName => $conversion_name,
conversionTime => $conversion_time,
conversionValue => $conversion_value,
googleClickId => $gclid,
# Optional: To upload fractional conversion credits, set the external
# attribution model and credit. To use this feature, your conversion tracker
# should be marked as externally attributed. See
# https://developers.google.com/adwords/api/docs/guides/conversion-tracking#importing_externally_attributed_conversions
# to learn more about importing externally attributed conversions.
# externalAttributionModel => "Linear";
# externalAttributionCredit => 0.3;
});
my $offline_conversion_operation =
Google::Ads::AdWords::v201809::OfflineConversionFeedOperation->new({
operator => "ADD",
operand => $feed
});
push @offline_conversion_operations, $offline_conversion_operation;
# Add the upload conversion.
my $feed_result =
$client->OfflineConversionFeedService()
->mutate({operations => \@offline_conversion_operations});
# Display results.
if ($feed_result->get_value()) {
foreach my $oc_feed (@{$feed_result->get_value()}) {
printf "Uploaded offline conversion value of \"%s\" for Google Click " .
"ID \"%s\" was created.\n",
$oc_feed->get_conversionName(),
$oc_feed->get_googleClickId();
}
} else {
print "No offline conversion were added.\n";
return;
}
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 => "v201809"});
# By default examples are set to die on any server returned fault.
$client->set_die_on_faults(1);
# Call the example
upload_offline_conversions($client, $conversion_name, $gclid, $conversion_time,
$conversion_value);
( run in 1.538 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )