Google-Ads-AdWords-Client

 view release on metacpan or  search on metacpan

examples/v201809/basic_operations/add_campaigns.pl  view on Meta::CPAN

            targetSearchNetwork        => 1,
            targetContentNetwork       => 1,
            targetPartnerSearchNetwork => 0
          }
        ),
        # Advertising channel type (required).
        advertisingChannelType => "SEARCH",
        # Frequency cap (non-required).
        frequencyCap => Google::Ads::AdWords::v201809::FrequencyCap->new({
            impressions => 5,
            timeUnit    => "DAY",
            level       => "ADGROUP"
          }
        ),
        settings => [
          # Advanced location targeting settings (non-required).
          Google::Ads::AdWords::v201809::GeoTargetTypeSetting->new({
              positiveGeoTargetType => "DONT_CARE",
              negativeGeoTargetType => "DONT_CARE"
            }
          ),
        ],
        # Additional properties (non-required).
        startDate                   => $today,
        endDate                     => $tomorrow,
        # Recommendation: Set the campaign to PAUSED when creating it to stop
        # the ads from immediately serving. Set to ENABLED once you've added
        # targeting and the ads are ready to serve.
        status                      => "PAUSED"
      });

    # Create operation.
    my $campaign_operation =
      Google::Ads::AdWords::v201809::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 => "v201809"});

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