GOOGLE-ADWORDS-PERL-CLIENT

 view release on metacpan or  search on metacpan

examples/v201309/advanced_operations/upload_offline_conversions.pl  view on Meta::CPAN


  # Display results.
  if ($tracker_result->get_value()) {
    foreach my $conversion_tracker (@{$tracker_result->get_value()}) {
      printf "New upload conversion type with name \"%s\" and ID \"%d\" " .
             "\"%s\" was created.\n",
             $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::v201309::OfflineConversionFeed->new({
    conversionName => $conversion_name,
    conversionTime => $conversion_time,
    conversionValue => $conversion_value,
    googleClickId => $gclid
  });

  my $offline_conversion_operation =
      Google::Ads::AdWords::v201309::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 \"%d\" was created.\n",
             $oc_feed->get_name(),
             $oc_feed->get_id();
    }
  } 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 => "v201309"});

# 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 0.763 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )