একটি থিংস টু ডু ক্যাম্পেইন তৈরি করা

থিংস টু ডু বিজ্ঞাপন বাস্তবায়নের প্রথম ধাপ হল একটি থিংস টু ডু ক্যাম্পেইন তৈরি করা। প্রচারাভিযান তৈরি করার সময়, আপনি এর বাজেট, বিডিং কৌশল এবং থিংস টু ডু সেন্টার অ্যাকাউন্ট আইডি সেট করেন।

এখানে একটি প্রচারাভিযান সেট আপ করার পদক্ষেপগুলি রয়েছে:

  1. ক্যাম্পেইনের advertising_channel_type কে TRAVEL এবং advertising_channel_sub_type কে TRAVEL_ACTIVITIES তে সেট করা।
  2. একটি TravelCampaignSettings তৈরি করা, তার travel_account_id সেট করা, এবং তারপর এটিকে প্রচারে যোগ করা।
  3. প্রচারণার জন্য একটি MaximizeConversionValue বিডিং কৌশল তৈরি করা।

নিম্নলিখিত কোড এই পদক্ষেপগুলি প্রদর্শন করে।

জাভা

private String addThingsToDoCampaign(
    GoogleAdsClient googleAdsClient,
    long customerId,
    String budgetResourceName,
    long thingsToDoCenterAccountId) {
  // Creates the campaign.
  Campaign campaign =
      Campaign.newBuilder()
          .setName("Interplanetary Cruise #" + getPrintableDateTime())
          // Configures settings related to Things to do campaigns including advertising channel
          // type, advertising channel sub type and travel campaign settings.
          .setAdvertisingChannelType(AdvertisingChannelType.TRAVEL)
          .setAdvertisingChannelSubType(AdvertisingChannelSubType.TRAVEL_ACTIVITIES)
          .setTravelCampaignSettings(
              TravelCampaignSettings.newBuilder().setTravelAccountId(thingsToDoCenterAccountId))
          // Recommendation: Sets the campaign to PAUSED when creating it to prevent
          // the ads from immediately serving. Set to ENABLED once you've added
          // targeting and the ads are ready to serve
          .setStatus(CampaignStatus.PAUSED)
          // Sets the bidding strategy to MaximizeConversionValue. Only this type can be used
          // for Things to do campaigns.
          .setMaximizeConversionValue(MaximizeConversionValue.newBuilder())
          // Sets the budget.
          .setCampaignBudget(budgetResourceName)
          // Configures the campaign network options. Only Google Search is allowed for
          // Things to do campaigns.
          .setNetworkSettings(NetworkSettings.newBuilder().setTargetGoogleSearch(true))
          .build();

  // Creates a campaign operation.
  CampaignOperation operation = CampaignOperation.newBuilder().setCreate(campaign).build();

  // Issues a mutate request to add the campaign.
  try (CampaignServiceClient campaignServiceClient =
      googleAdsClient.getLatestVersion().createCampaignServiceClient()) {
    MutateCampaignsResponse response =
        campaignServiceClient.mutateCampaigns(
            Long.toString(customerId), Collections.singletonList(operation));
    MutateCampaignResult result = response.getResults(0);
    System.out.printf(
        "Added a Things to do campaign with resource name: '%s'%n", result.getResourceName());
    return result.getResourceName();
  }
}
      

সি#

// Creates a campaign.
Campaign campaign = new Campaign()
{
    Name = "Interplanetary Cruise #" + ExampleUtilities.GetRandomString(),
    AdvertisingChannelType = AdvertisingChannelType.Travel,
    AdvertisingChannelSubType = AdvertisingChannelSubType.TravelActivities,

    TravelCampaignSettings = new TravelCampaignSettings()
    {
        TravelAccountId = thingsToDoCenterAccountId
    },

    // Recommendation: Set the campaign to PAUSED when creating it to prevent
    // the ads from immediately serving. Set to ENABLED once you've added
    // targeting and the ads are ready to serve
    Status = CampaignStatus.Paused,

    // Set the bidding strategy and budget.
    MaximizeConversionValue = new MaximizeConversionValue(),
    CampaignBudget = budget,

    // Set the campaign network options.
    NetworkSettings = new NetworkSettings
    {
        TargetGoogleSearch = true
    }
};
      

পিএইচপি

private static function addThingsToDoCampaign(
    GoogleAdsClient $googleAdsClient,
    int $customerId,
    string $budgetResourceName,
    int $thingsToDoCenterAccountId
) {
    // Creates a campaign.
    $campaign = new Campaign([
        'name' => 'Interplanetary Cruise Campaign #' . Helper::getPrintableDatetime(),
        // Configures settings related to Things to do campaigns including advertising channel
        // type, advertising channel sub type and travel campaign settings.
        'advertising_channel_type' => AdvertisingChannelType::TRAVEL,
        'advertising_channel_sub_type' => AdvertisingChannelSubType::TRAVEL_ACTIVITIES,
        'travel_campaign_settings'
            => new TravelCampaignSettings(['travel_account_id' => $thingsToDoCenterAccountId]),
        // Recommendation: Set the campaign to PAUSED when creating it to prevent
        // the ads from immediately serving. Set to ENABLED once you've added
        // targeting and the ads are ready to serve.
        'status' => CampaignStatus::PAUSED,
        // Sets the bidding strategy to MaximizeConversionValue. Only this type can be used
        // for Things to do campaigns.
        'maximize_conversion_value' => new MaximizeConversionValue(),
        // Sets the budget.
        'campaign_budget' => $budgetResourceName,
        // Configures the campaign network options. Only Google Search is allowed for
        // Things to do campaigns.
        'network_settings' => new NetworkSettings(['target_google_search' => true])
    ]);

    // Creates a campaign operation.
    $campaignOperation = new CampaignOperation();
    $campaignOperation->setCreate($campaign);

    // Issues a mutate request to add campaigns.
    $campaignServiceClient = $googleAdsClient->getCampaignServiceClient();
    $response = $campaignServiceClient->mutateCampaigns(
        MutateCampaignsRequest::build($customerId, [$campaignOperation])
    );

    /** @var Campaign $addedCampaign */
    $addedCampaign = $response->getResults()[0];
    printf(
        "Added a Things to do campaign with resource name '%s'.%s",
        $addedCampaign->getResourceName(),
        PHP_EOL
    );

    return $addedCampaign->getResourceName();
}
      

পাইথন

def add_things_to_do_campaign(
    client, customer_id, budget_resource_name, things_to_do_center_account_id
):
    """Creates a new Things to do campaign in the specified customer account.

    Args:
        client: an initialized GoogleAdsClient instance.
        customer_id: a client customer ID.
        budget_resource_name: the resource name of a budget for a new campaign.
        things_to_do_center_account_id: the Things to Do Center account ID.

    Returns:
        The resource name of the newly created campaign.
    """
    # Creates a campaign operation.
    operation = client.get_type("CampaignOperation")
    # Creates a campaign.
    campaign = operation.create
    campaign.name = (
        f"Interplanetary Cruise Campaign #{get_printable_datetime()}"
    )
    # Configures settings related to Things to do campaigns including
    # advertising channel type, advertising channel sub type and travel
    # campaign settings.
    campaign.advertising_channel_type = (
        client.enums.AdvertisingChannelTypeEnum.TRAVEL
    )
    campaign.advertising_channel_sub_type = (
        client.enums.AdvertisingChannelSubTypeEnum.TRAVEL_ACTIVITIES
    )
    campaign.travel_campaign_settings.travel_account_id = (
        things_to_do_center_account_id
    )
    # Recommendation: Set the campaign to PAUSED when creating it to prevent
    # the ads from immediately serving. Set to ENABLED once you've added
    # targeting and the ads are ready to serve.
    campaign.status = client.enums.CampaignStatusEnum.PAUSED
    # Sets the bidding strategy to MaximizeConversionValue. Only this type can
    # be used for Things to do campaigns.
    campaign.maximize_conversion_value = client.get_type(
        "MaximizeConversionValue"
    )
    # Sets the budget.
    campaign.campaign_budget = budget_resource_name
    # Configures the campaign network options. Only Google Search is allowed for
    # Things to do campaigns.
    campaign.network_settings.target_google_search = True

    # Issues a mutate request to add campaigns.
    campaign_service = client.get_service("CampaignService")
    response = campaign_service.mutate_campaigns(
        customer_id=customer_id, operations=[operation]
    )

    resource_name = response.results[0].resource_name
    print(
        f"Added a Things to do campaign with resource name: '{resource_name}'."
    )
    return resource_name
      

রুবি

def add_things_to_do_campaign(client, customer_id, budget_resource,
  things_to_do_center_account_id)

  # Create a campaign.
  campaign_operation = client.operation.create_resource.campaign do |c|
    c.name = generate_random_name_field("Interplanetary Cruise Campaign")

    #  Configures settings related to Things to Do campaigns including
    # advertising channel type, advertising channel sub type and
    # travel campaign settings.
    c.advertising_channel_type = :TRAVEL
    c.advertising_channel_sub_type = :TRAVEL_ACTIVITIES

    c.travel_campaign_settings = client.resource.travel_campaign_settings do |tcs|
      tcs.travel_account_id = things_to_do_center_account_id
    end

    # Recommendation: Set the campaign to PAUSED when creating it to prevent the
    # ads from immediately serving. Set to ENABLED once you've added targeting
    # and the ads are ready to serve.
    c.status = :PAUSED

    # Sets the bidding strategy to MaximizeConversionValue. Only this type can
    # be used for Things to Do campaigns.
    c.maximize_conversion_value = client.resource.maximize_conversion_value

    # Set the budget.
    c.campaign_budget = budget_resource

    # Configures the campaign network options. Only Google Search is allowed for
    # Things to Do campaigns.
    c.network_settings = client.resource.network_settings do |ns|
      ns.target_google_search = true
    end
  end

  # Issue a mutate request to add the campaign.
  campaign_service = client.service.campaign
  response = campaign_service.mutate_campaigns(
    customer_id: customer_id,
    operations: [campaign_operation],
  )

  # Fetch the new campaign's resource name.
  campaign_resource = response.results.first.resource_name

  puts "Added Things To Do campaign with resource name '#{campaign_resource}'."

  campaign_resource
end
      

পার্ল

sub add_things_to_do_campaign {
  my ($api_client, $customer_id, $budget_resource_name,
    $things_to_do_center_account_id)
    = @_;

  # Create a campaign.
  my $campaign = Google::Ads::GoogleAds::V17::Resources::Campaign->new({
      name => "Interplanetary Cruise Campaign #" . uniqid(),
      # Configure settings related to Things to do campaigns including
      # advertising channel type, advertising channel sub type and travel
      # campaign settings.
      advertisingChannelType    => TRAVEL,
      advertisingChannelSubType => TRAVEL_ACTIVITIES,
      travelCampaignSettings    =>
        Google::Ads::GoogleAds::V17::Resources::TravelCampaignSettings->new({
          travelAccountId => $things_to_do_center_account_id
        }
        ),
      # Recommendation: Set the campaign to PAUSED when creating it to prevent
      # the ads from immediately serving. Set to ENABLED once you've added
      # targeting and the ads are ready to serve.
      status => Google::Ads::GoogleAds::V17::Enums::CampaignStatusEnum::PAUSED,
      # Set the bidding strategy to MaximizeConversionValue. Only this type can be
      # used for Things to do campaigns.
      maximizeConversionValue =>
        Google::Ads::GoogleAds::V17::Common::MaximizeConversionValue->new(),
      # Set the budget.
      campaignBudget => $budget_resource_name,
      # Configure the campaign network options. Only Google Search is allowed for
      # Things to do campaigns.
      networkSettings =>
        Google::Ads::GoogleAds::V17::Resources::NetworkSettings->new({
          targetGoogleSearch => "true"
        })});

  # Create a campaign operation.
  my $campaign_operation =
    Google::Ads::GoogleAds::V17::Services::CampaignService::CampaignOperation->
    new({create => $campaign});

  # Add the campaign.
  my $campaign_resource_name = $api_client->CampaignService()->mutate({
      customerId => $customer_id,
      operations => [$campaign_operation]})->{results}[0]{resourceName};

  printf "Added a Things to do campaign with resource name: '%s'.\n",
    $campaign_resource_name;

  return $campaign_resource_name;
}