استرداد عمليات محاكاة عروض الأسعار

تتكوّن محاكاة عروض الأسعار من بيانات المحاكاة ومعلومات عن النطاق الزمني أو نوع بيانات المحاكاة أو الحملة أو المجموعة الإعلانية أو المعيار الذي تتعلّق به. بيانات المحاكاة هي تسلسل من نقاط المحاكاة التي تقدّم مخطّطًا بيانيًا للأداء المتوقّع باستخدام عروض أسعار مختلفة خلال الإطار الزمني المحدّد. تعتمد المعلومات التي تقدّمها نقطة المحاكاة على نوع بيانات المحاكاة.

يمكن استرداد أيّ محاكاة عروض أسعار باستخدام طلب بحث في "لغة الاستعلامات في "إحصاءات Google" (GAQL) من خلال اختيار حقل بيانات المحاكاة المناسب (نوع بيانات المحاكاة) من المصدر المناسب (مستوى عرض السعر).

مستوى عرض السعر والمورد SimulationType حقل بيانات المحاكاة نوع نقطة المحاكاة
المجموعة الإعلانية

ad_group_simulation

CPC_BID

CPV_BID

TARGET_CPA

TARGET_ROAS

cpc_bid_point_list.points

cpv_bid_point_list.points

target_cpa_point_list.points

target_roas_point_list.points

CpcBidSimulationPoint

CpvBidSimulationPoint

TargetCpaSimulationPoint

TargetRoasSimulationPoint

معيار المجموعة الإعلانية

ad_group_criterion_simulation

CPC_BID cpc_bid_point_list.points CpcBidSimulationPoint
استراتيجية عروض الأسعار (المحفظة)

bidding_strategy_simulation

TARGET_CPA

TARGET_ROAS

target_cpa_point_list.points

target_roas_point_list.points

TargetCpaSimulationPoint

TargetRoasSimulationPoint

الحملة

campaign_simulation

BUDGET

CPC_BID

TARGET_CPA

TARGET_IMPRESSION_SHARE

TARGET_ROAS
ملاحظة: بالنسبة إلى "حملات التطبيقات"، يتوفّر هذا النوع من المحاكاة لإصدار Google Ads API 16_1 أو الإصدارات الأحدث.

budget_point_list.points

cpc_bid_point_list.points

target_cpa_point_list.points

target_impression_share_point_list.points

target_roas_point_list.points

BudgetSimulationPoint

CpcBidSimulationPoint

TargetCpaSimulationPoint

TargetImpressionShareSimulationPoint

TargetRoasSimulationPoint

طريقة تعديل محاكاة التوسّع في محاكاات الحملات

تتيح المحاكاة على مستوى الحملة طريقة تعديل محاكاة خاصة تُعرف باسم SCALING. عندما يكون CampaignSimulation يحتوي على طريقة التعديل SCALING، يعرض ما يحدث إذا كانت تتم ترقية جميع عروض أسعار الكلمات الرئيسية بمُعدِّل التوسيع المحدَّد. على سبيل المثال، عندما يكون مُعدِّل التوسيع هو 2.0، يعرض ما يحدث إذا تم مضاعفة جميع عروض أسعار الكلمات الرئيسية. لمزيد من المعلومات، اطّلِع على المقالة حول كيفية تقدير نتائجك باستخدام مُحاكيات عروض الأسعار والميزانيات والاستهدافات.

يوضّح المثال التالي كيفية استرداد وطباعة جميع سيناريوهات عروض الأسعار المستندة إلى تكلفة النقرة والتي تتوفّر لأيّ معايير لمجموعة إعلانية معيّنة يتمّ فلترتها حسب رقم تعريفها.

Java

private void runExample(GoogleAdsClient googleAdsClient, long customerId, long adGroupId) {
  try (GoogleAdsServiceClient googleAdsServiceClient =
      googleAdsClient.getLatestVersion().createGoogleAdsServiceClient()) {
    // Creates a query that retrieves the ad group criterion CPC bid simulations.
    String query =
        String.format(
            "SELECT ad_group_criterion_simulation.ad_group_id, "
                + "ad_group_criterion_simulation.criterion_id, "
                + "ad_group_criterion_simulation.start_date, "
                + "ad_group_criterion_simulation.end_date, "
                + "ad_group_criterion_simulation.cpc_bid_point_list.points "
                + "FROM ad_group_criterion_simulation "
                + "WHERE ad_group_criterion_simulation.type = CPC_BID "
                + "AND ad_group_criterion_simulation.ad_group_id = %d",
            adGroupId);
    // Constructs the SearchGoogleAdsStreamRequest.
    SearchGoogleAdsStreamRequest request =
        SearchGoogleAdsStreamRequest.newBuilder()
            .setCustomerId(Long.toString(customerId))
            .setQuery(query)
            .build();

    // Issues the search stream request.
    ServerStream<SearchGoogleAdsStreamResponse> stream =
        googleAdsServiceClient.searchStreamCallable().call(request);

    // Iterates over all rows in all messages and prints the requested field values for
    // the ad group criterion CPC bid simulation in each row.
    for (SearchGoogleAdsStreamResponse response : stream) {
      for (GoogleAdsRow googleAdsRow : response.getResultsList()) {
        AdGroupCriterionSimulation simulation = googleAdsRow.getAdGroupCriterionSimulation();
        System.out.printf(
            "Found ad group criterion CPC bid simulation for ad group ID %d, "
                + "criterion ID %d, start date '%s', end date '%s', and points:%n",
            simulation.getAdGroupId(),
            simulation.getCriterionId(),
            simulation.getStartDate(),
            simulation.getEndDate());
        for (CpcBidSimulationPoint point : simulation.getCpcBidPointList().getPointsList()) {
          System.out.printf(
              "  bid: %d => clicks: %d, cost: %d, impressions: %d, "
                  + "biddable conversions: %.2f, biddable conversions value: %.2f%s",
              point.getCpcBidMicros(),
              point.getClicks(),
              point.getCostMicros(),
              point.getImpressions(),
              point.getBiddableConversions(),
              point.getBiddableConversions());
        }
      }
    }
  }
}
      

#C

public void Run(GoogleAdsClient client, long customerId, long adGroupId)
{
    // Get the GoogleAdsService.
    GoogleAdsServiceClient googleAdsService =
        client.GetService(Services.V18.GoogleAdsService);

    try
    {
        // Creates a query that retrieves the ad group criterion CPC bid simulations.
        string query = $@"
            SELECT
                ad_group_criterion_simulation.ad_group_id,
                ad_group_criterion_simulation.criterion_id,
                ad_group_criterion_simulation.start_date,
                ad_group_criterion_simulation.end_date,
                ad_group_criterion_simulation.cpc_bid_point_list.points
            FROM
                ad_group_criterion_simulation
            WHERE
                ad_group_criterion_simulation.type = CPC_BID AND
                ad_group_criterion_simulation.ad_group_id = {adGroupId}";

        // Issue a search stream request.
        googleAdsService.SearchStream(customerId.ToString(), query,
            delegate (SearchGoogleAdsStreamResponse response)
            {
                // Iterates over all rows in all messages and prints the requested field
                // values for the ad group criterion CPC bid simulation in each row.
                foreach (GoogleAdsRow googleAdsRow in response.Results)
                {
                    AdGroupCriterionSimulation simulation =
                        googleAdsRow.AdGroupCriterionSimulation;

                    Console.WriteLine("Found ad group criterion CPC bid simulation for " +
                        $"ad group ID {simulation.AdGroupId}, " +
                        $"criterion ID {simulation.CriterionId}, " +
                        $"start date {simulation.StartDate}, " +
                        $"end date {simulation.EndDate}");

                    foreach (CpcBidSimulationPoint point in
                        simulation.CpcBidPointList.Points)
                    {
                        Console.WriteLine($"\tbid: {point.CpcBidMicros} => " +
                            $"clicks: {point.Clicks}, " +
                            $"cost: {point.CostMicros}, " +
                            $"impressions: {point.Impressions}, " +
                            $"biddable conversions: {point.BiddableConversions}, " +
                            "biddable conversions value: " +
                            $"{point.BiddableConversionsValue}");
                    }

                    Console.WriteLine();
                }
            }
        );
    }
      

PHP

public static function runExample(
    GoogleAdsClient $googleAdsClient,
    int $customerId,
    int $adGroupId
) {
    $googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();

    // Creates a query that retrieves the ad group criterion CPC bid simulations.
    $query = sprintf(
        'SELECT ad_group_criterion_simulation.ad_group_id, ' .
        'ad_group_criterion_simulation.criterion_id, ' .
        'ad_group_criterion_simulation.start_date, ' .
        'ad_group_criterion_simulation.end_date, ' .
        'ad_group_criterion_simulation.cpc_bid_point_list.points ' .
        'FROM ad_group_criterion_simulation ' .
        'WHERE ad_group_criterion_simulation.type = CPC_BID ' .
        'AND ad_group_criterion_simulation.ad_group_id = %d',
        $adGroupId
    );

    // Issues a search stream request.
    /** @var GoogleAdsServerStreamDecorator $stream */
    $stream = $googleAdsServiceClient->searchStream(
        SearchGoogleAdsStreamRequest::build($customerId, $query)
    );

    // Iterates over all rows in all messages and prints the requested field values for
    // the ad group criterion CPC bid simulation in each row.
    foreach ($stream->iterateAllElements() as $googleAdsRow) {
        /** @var GoogleAdsRow $googleAdsRow */
        $simulation = $googleAdsRow->getAdGroupCriterionSimulation();
        printf(
            'Found ad group criterion CPC bid simulation for ad group ID %d, ' .
            'criterion ID %d, start date "%s", end date "%s", and points:%s',
            $simulation->getAdGroupId(),
            $simulation->getCriterionId(),
            $simulation->getStartDate(),
            $simulation->getEndDate(),
            PHP_EOL
        );
        foreach ($simulation->getCpcBidPointList()->getPoints() as $point) {
            /** @var CpcBidSimulationPoint $point */
            printf(
                '  bid: %d => clicks: %d, cost: %d, impressions: %d, ' .
                'biddable conversions: %.2f, biddable conversions value: %.2f%s',
                $point->getCpcBidMicros(),
                $point->getClicks(),
                $point->getCostMicros(),
                $point->getImpressions(),
                $point->getBiddableConversions(),
                $point->getBiddableConversionsValue(),
                PHP_EOL
            );
        }

        print PHP_EOL;
    }
}
      

Python

def main(client, customer_id, ad_group_id):
    googleads_service = client.get_service("GoogleAdsService")

    query = f"""
        SELECT
          ad_group_criterion_simulation.ad_group_id,
          ad_group_criterion_simulation.criterion_id,
          ad_group_criterion_simulation.start_date,
          ad_group_criterion_simulation.end_date,
          ad_group_criterion_simulation.cpc_bid_point_list.points
        FROM ad_group_criterion_simulation
        WHERE
          ad_group_criterion_simulation.type = CPC_BID
          AND ad_group_criterion_simulation.ad_group_id = {ad_group_id}"""

    # Issues a search request using streaming.
    stream = googleads_service.search_stream(
        customer_id=customer_id, query=query
    )

    # Iterates over all rows in all messages and prints the requested field
    # values for the ad group criterion CPC bid simulation in each row.
    for batch in stream:
        for row in batch.results:
            simulation = row.ad_group_criterion_simulation

            print(
                "found ad group criterion CPC bid simulation for "
                f"ad group ID {simulation.ad_group_id}, "
                f"criterion ID {simulation.criterion_id}, "
                f"start date {simulation.start_date}, "
                f"end date {simulation.end_date}"
            )

            for point in simulation.cpc_bid_point_list.points:
                print(
                    f"\tbid: {point.cpc_bid_micros} => "
                    f"clicks: {point.clicks}",
                    f"cost: {point.cost_micros}, "
                    f"impressions: {point.impressions},"
                    "biddable conversions: "
                    f"{point.biddable_conversions},"
                    f"biddable conversions value: "
                    f"{point.biddable_conversions_value}",
                )

            print()
      

Ruby

def get_ad_group_criterion_cpc_bid_simulations(customer_id, ad_group_id)
  # GoogleAdsClient will read a config file from
  # ENV['HOME']/google_ads_config.rb when called without parameters
  client = Google::Ads::GoogleAds::GoogleAdsClient.new

  query = <<~QUERY
    SELECT ad_group_criterion_simulation.ad_group_id,
           ad_group_criterion_simulation.criterion_id,
           ad_group_criterion_simulation.start_date,
           ad_group_criterion_simulation.end_date,
           ad_group_criterion_simulation.cpc_bid_point_list.points
    FROM ad_group_criterion_simulation
    WHERE ad_group_criterion_simulation.type = CPC_BID 
    AND ad_group_criterion_simulation.ad_group_id = #{ad_group_id}
  QUERY

  responses = client.service.google_ads.search_stream(
    customer_id: customer_id,
    query: query,
  )

  responses.each do |response|
    response.results.each do |row|
      simulation = row.ad_group_criterion_simulation

      puts "Found ad group criterion CPC bid simulation for " \
      "ad group ID #{simulation.ad_group_id}, " \
      "criterion ID #{simulation.criterion_id}, " \
      "start date '#{simulation.start_date}', " \
      "end date '#{simulation.end_date}', and points:"

      simulation.cpc_bid_point_list.points.each do |point|
        puts "  bid: #{point.cpc_bid_micros} => " \
        "clicks: #{point.clicks}, " \
        "cost: #{point.cost_micros}, " \
        "impressions: #{point.impressions}, " \
        "biddable conversions: #{point.biddable_conversions.round(2)}, " \
        "biddable conversions value: #{point.biddable_conversions_value.round(2)}"
      end
    end
  end
end
      

Perl

sub get_ad_group_criterion_cpc_bid_simulations {
  my ($api_client, $customer_id, $ad_group_id) = @_;

  # Create a query that retrieves the ad group criterion CPC bid simulations.
  my $search_query =
    "SELECT ad_group_criterion_simulation.ad_group_id, " .
    "ad_group_criterion_simulation.criterion_id, " .
    "ad_group_criterion_simulation.start_date, " .
    "ad_group_criterion_simulation.end_date, " .
    "ad_group_criterion_simulation.cpc_bid_point_list.points " .
    "FROM ad_group_criterion_simulation " .
    "WHERE ad_group_criterion_simulation.type = CPC_BID " .
    "AND ad_group_criterion_simulation.ad_group_id = $ad_group_id";

  my $search_stream_request =
    Google::Ads::GoogleAds::V18::Services::GoogleAdsService::SearchGoogleAdsStreamRequest
    ->new({
      customerId => $customer_id,
      query      => $search_query
    });

  # Get the GoogleAdsService.
  my $google_ads_service = $api_client->GoogleAdsService();

  my $search_stream_handler =
    Google::Ads::GoogleAds::Utils::SearchStreamHandler->new({
      service => $google_ads_service,
      request => $search_stream_request
    });

  # Issue a search stream request, iterate over all rows in all messages and
  # print the requested field values for the ad group criterion CPC bid
  # simulation in each row.
  $search_stream_handler->process_contents(
    sub {
      my $google_ads_row = shift;
      my $simulation     = $google_ads_row->{adGroupCriterionSimulation};

      printf
        "Found ad group criterion CPC bid simulation for ad group ID %d, " .
        "criterion ID %d, start date '%s', end date '%s', and points:\n",
        $simulation->{adGroupId}, $simulation->{criterionId},
        $simulation->{startDate}, $simulation->{endDate};

      foreach my $point (@{$simulation->{cpcBidPointList}{points}}) {
        printf "  bid: %d => clicks: %d, cost: %d, impressions: %d, " .
          "biddable conversions: %.2f, biddable conversions value: %.2f\n",
          $point->{cpcBidMicros},
          $point->{clicks},
          $point->{costMicros},
          $point->{impressions},
          $point->{biddableConversions},
          $point->{biddableConversionsValue};
      }
    });

  return 1;
}