Example: Creating a dynamic remarketing campaign with Google Merchant Center

In this example, you have a retail site that uploads product listings to Google Merchant Center and you want to remarket groups of products to users who visited the retail site. These users might have visited a product page or placed an item in a basket or checkout, recorded by the triggering of a remarketing tag. You can then create a campaign to target only this group or expand to similar audiences to increase your reach.

Read more about audience list generation best practices.

You will need the following to set up such a campaign:

  1. Remarketing List.
  2. Merchant Center account.
  3. Product Feed from Merchant Center.
  4. Media required for Responsive Ads for Display.

Here is the list of ad creatives that support Merchant Center product feeds:

Step 1 - Create a campaign linked to a Merchant Center product feed

In order to be able to remarket retail products, you'll need to create a campaign targeting the Display Network. This will require the following:

  • A CampaignBudget to specify how much the campaign is able to spend.
  • A UserList including the list of users to target with the campaign.
  • A ShoppingSetting to specify which Merchant Center account the product feed will be used for the campaign.

The basic steps for configuring the campaign are:

  1. Create a new campaign, setting the AdvertisingChannelType to DISPLAY.

  2. Set the CampaignBudget for the campaign. This can be a newly created budget or a shared budget.

  3. Set the ShoppingSetting for the campaign. Note that the CampaignService is used here, rather than AdGroupService, since the feed must be attached at campaign level.

  4. Apply the mutate operation to add the new campaign to the account.

Code Example

private String createCampaign(
    GoogleAdsClient googleAdsClient,
    long customerId,
    long merchantCenterAccountId,
    long campaignBudgetId) {
  String budgetResourceName = ResourceNames.campaignBudget(customerId, campaignBudgetId);

  // Creates the campaign.
  Campaign campaign =
          .setName("Shopping campaign #" + getPrintableDateTime())
          // Dynamic remarketing campaigns are only available on the Google Display Network.
          // The settings for the shopping campaign.
          // This connects the campaign to the merchant center account.
                  // Display Network campaigns do not support partition by country. The only
                  // supported value is "ZZ". This signals that products from all countries are
                  // available in the campaign. The actual products which serve are based on
                  // the products tagged in the user list entry.

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

  // Creates the campaign service client.
  try (CampaignServiceClient campaignServiceClient =
      googleAdsClient.getLatestVersion().createCampaignServiceClient()) {
    // Adds the campaign.
    MutateCampaignsResponse response =
            Long.toString(customerId), ImmutableList.of(operation));
    String campaignResourceName = response.getResults(0).getResourceName();
    System.out.printf("Created campaign with resource name '%s'.%n", campaignResourceName);
    return campaignResourceName;

Step 2 - Create an ad group for the remarketing campaign

Code Example

private String createAdGroup(
    GoogleAdsClient googleAdsClient, long customerId, String campaignResourceName) {
  // Creates the ad group.
  AdGroup adGroup =
          .setName("Dynamic remarketing ad group")

  // Creates the ad group operation.
  AdGroupOperation operation = AdGroupOperation.newBuilder().setCreate(adGroup).build();

  // Creates the ad group service client.
  try (AdGroupServiceClient adGroupServiceClient =
      googleAdsClient.getLatestVersion().createAdGroupServiceClient()) {
    // Adds the ad group.
    MutateAdGroupsResponse response =
            Long.toString(customerId), ImmutableList.of(operation));
    String adGroupResourceName = response.getResults(0).getResourceName();
    System.out.printf("Created ad group with resource name '%s'.%n", adGroupResourceName);
    return adGroupResourceName;

Step 3 - Create a responsive ad for display

Code Example

private void createAd(
    GoogleAdsClient googleAdsClient, long customerId, String adGroupResourceName)
    throws IOException {
  String marketingImageUrl = "https://goo.gl/3b9Wfh";
  String marketingImageName = "Marketing Image";
  String marketingImageResourceName =
      uploadAsset(googleAdsClient, customerId, marketingImageUrl, marketingImageName);
  String squareMarketingImageName = "Square Marketing Image";
  String squareMarketingImageUrl = "https://goo.gl/mtt54n";
  String squareMarketingImageResourceName =
      uploadAsset(googleAdsClient, customerId, squareMarketingImageUrl, squareMarketingImageName);

  // Creates the responsive display ad info object.
  ResponsiveDisplayAdInfo responsiveDisplayAdInfo =
          .setLongHeadline(AdTextAsset.newBuilder().setText("Travel the World").build())
          .addDescriptions(AdTextAsset.newBuilder().setText("Take to the air!").build())
          .setBusinessName("Interplanetary Cruises")
          // Optional: Call to action text.
          // Valid texts: https://support.google.com/adwords/answer/7005917
          .setCallToActionText("Apply Now")
          // Optional: Sets the ad colors.
          // Optional: Sets to false to strictly render the ad using the colors.
          // Optional: Sets the format setting that the ad will be served in.
          // Optional: Creates a logo image and sets it to the ad.
          // Optional: Creates a square logo image and sets it to the ad.

  // Creates the ad.
  Ad ad =

  // Creates the ad group ad.
  AdGroupAd adGroupAd = AdGroupAd.newBuilder().setAdGroup(adGroupResourceName).setAd(ad).build();

  // Creates the ad group ad operation.
  AdGroupAdOperation operation = AdGroupAdOperation.newBuilder().setCreate(adGroupAd).build();

  // Creates the ad group ad service client.
  try (AdGroupAdServiceClient adGroupAdServiceClient =
      googleAdsClient.getLatestVersion().createAdGroupAdServiceClient()) {
    // Adds the ad group ad.
    MutateAdGroupAdsResponse response =
            Long.toString(customerId), ImmutableList.of(operation));
        "Created ad group ad with resource name '%s'.%n",

Step 4 - Target a user list

Code Example

private void attachUserList(
    GoogleAdsClient googleAdsClient,
    long customerId,
    String adGroupResourceName,
    long userListId) {
  String userListResourceName = ResourceNames.userList(customerId, userListId);
  // Creates the ad group criterion that targets the user list.
  AdGroupCriterion adGroupCriterion =

  // Creates the ad group criterion operation.
  AdGroupCriterionOperation operation =

  // Creates the ad group criterion service client.
  try (AdGroupCriterionServiceClient adGroupCriterionServiceClient =
      googleAdsClient.getLatestVersion().createAdGroupCriterionServiceClient()) {
    // Adds the ad group criterion.
    MutateAdGroupCriteriaResponse response =
            Long.toString(customerId), ImmutableList.of(operation));
        "Created ad group criterion with resource name '%s'.%n",

Once you've set up the dynamic remarketing campaign for your Merchant Center feeds, you can use the Ad Preview tool from your Google Ads account to see the contents pulled from your Merchant Center feeds.