Adwords API to GoogleAds API Migration

103 views
Skip to first unread message

shashank chandel

unread,
Aug 3, 2022, 2:04:40 PM8/3/22
to Google Ads API and AdWords API Forum
Hi Team,
I'm trying to find the equivalent code sample for "create a remarketing user list audience" in the new Google Ads API. I couldn't find any code sample in the new Google Ads API. Can anyone help with this?  https://developers.google.com/adwords/api/docs/samples/java/remarketing#create-a-remarketing-user-list-audience



Thanks
shashank

Google Ads API Forum Advisor

unread,
Aug 3, 2022, 3:23:39 PM8/3/22
to shashak...@gmail.com, adwor...@googlegroups.com
Hi Shashank,

Thank you for raising this concern to the Google Ads API Forum.

With regard to your concern, the equivalent code sample for "create a remarketing user list audience" in Google Ads API is the Customer Match. Also, you may check these Libraries & Examples to Add Customer Match User List. Let me know if you have any questions with the provided documents.

Best regards,
Google Logo
Jinky
Google Ads API Team
 


ref:_00D1U1174p._5004Q2d4Xta:ref

shashank chandel

unread,
Aug 3, 2022, 4:23:26 PM8/3/22
to Google Ads API and AdWords API Forum
Hi, thanks for reply. Actually I’m trying to relate the links you shared regarding AddCustomerMatch. I have few doubts :

- Is adding remarketing user list audience is same as adding customer march user list?
- how conversion tracker service is mapped to this ?because In old api sample there is usage of conversiontype and I’m looking similar.

- what is the new api equivalent to the below code specifically conversiontracker service, create conversion type, getting and displaying  conversion ids and trackers.

Thanks
————
Get the ConversionTrackerService.
    ConversionTrackerServiceInterface conversionTrackerService =
        adWordsServices.get(session, ConversionTrackerServiceInterface.class);

    // Create conversion type (tag). (## Get the ConversionTrackerService.
    ConversionTrackerServiceInterface conversionTrackerService =
        adWordsServices.get(session, ConversionTrackerServiceInterface.class);

    // Create conversion type (tag).
    UserListConversionType conversionType = new UserListConversionType();
    conversionType.setName("Mars cruise customers #" + System.currentTimeMillis());

    // Create remarketing user list.
    BasicUserList userList = new BasicUserList();
    userList.setName("Mars cruise customers #" + System.currentTimeMillis());
    userList.setDescription("A list of mars cruise customers in the last year");
    userList.setMembershipLifeSpan(365L);
    userList.setConversionTypes(new UserListConversionType[] {conversionType});

    // You can optionally provide these field(s).
    userList.setStatus(UserListMembershipStatus.OPEN);

    // Create operations.
    UserListOperation operation = new UserListOperation();
    operation.setOperand(userList);
    operation.setOperator(Operator.ADD);

    UserListOperation[] operations = new UserListOperation[] {operation};

    // Add user list.
    UserListReturnValue result = userListService.mutate(operations);

    // Display results.
    // Capture the ID(s) of the conversion.
    List<String> conversionIds = new ArrayList<>();
    for (UserList userListResult : result.getValue()) {
      if (userListResult instanceof BasicUserList) {
        BasicUserList remarketingUserList = (BasicUserList) userListResult;
        for (UserListConversionType userListConversionType :
            remarketingUserList.getConversionTypes()) {
          conversionIds.add(userListConversionType.getId().toString());
        }
      }
    }

    // Create predicate and selector.
    Selector selector = new SelectorBuilder()
        .fields("Id", "GoogleGlobalSiteTag", "GoogleEventSnippet")
        .in(AdwordsUserListField.Id, conversionIds.toArray(new String[0]))
        .build();

    // Get all conversion trackers.
    Map<Long, AdWordsConversionTracker> conversionTrackers =
        new HashMap<Long, AdWordsConversionTracker>();
    ConversionTrackerPage page = conversionTrackerService.get(selector);
    if (page != null && page.getEntries() != null) {
      conversionTrackers =
          Arrays.stream(page.getEntries())
              .collect(
                  Collectors.toMap(
                      conversionTracker -> conversionTracker.getId(),
                      conversionTracker -> (AdWordsConversionTracker) conversionTracker));
    }
 one)
    UserListConversionType conversionType = new UserListConversionType();
    conversionType.setName("Mars cruise customers #" + System.currentTimeMillis());

    // Create remarketing user list.
    BasicUserList userList = new BasicUserList();
    userList.setName("Mars cruise customers #" + System.currentTimeMillis());
    userList.setDescription("A list of mars cruise customers in the last year");
    userList.setMembershipLifeSpan(365L);
    userList.setConversionTypes(new UserListConversionType[] {conversionType});

    // You can optionally provide these field(s).
    userList.setStatus(UserListMembershipStatus.OPEN);

    // Create operations.
    UserListOperation operation = new UserListOperation();
    operation.setOperand(userList);
    operation.setOperator(Operator.ADD);

    UserListOperation[] operations = new UserListOperation[] {operation};

    // Add user list.
    UserListReturnValue result = userListService.mutate(operations);

    // Display results.
    // Capture the ID(s) of the conversion.
    List<String> conversionIds = new ArrayList<>();
    for (UserList userListResult : result.getValue()) {
      if (userListResult instanceof BasicUserList) {
        BasicUserList remarketingUserList = (BasicUserList) userListResult;
        for (UserListConversionType userListConversionType :
            remarketingUserList.getConversionTypes()) {
          conversionIds.add(userListConversionType.getId().toString());
        }
      }
    }

    // Create predicate and selector.
    Selector selector = new SelectorBuilder()
        .fields("Id", "GoogleGlobalSiteTag", "GoogleEventSnippet")
        .in(AdwordsUserListField.Id, conversionIds.toArray(new String[0]))
        .build();

    // Get all conversion trackers.
    Map<Long, AdWordsConversionTracker> conversionTrackers =
        new HashMap<Long, AdWordsConversionTracker>();
    ConversionTrackerPage page = conversionTrackerService.get(selector);
    if (page != null && page.getEntries() != null) {
      conversionTrackers =
          Arrays.stream(page.getEntries())
              .collect(
                  Collectors.toMap(
                      conversionTracker -> conversionTracker.getId(),
                      conversionTracker -> (AdWordsConversionTracker) conversionTracker));
    }

Google Ads API Forum Advisor

unread,
Aug 3, 2022, 11:28:02 PM8/3/22
to shashak...@gmail.com, adwor...@googlegroups.com
Hi Shashank,

Thank you for getting back to us. I am Sherwin from Google Ads API and I work with Jinky. I hope that you are doing well today.

Moving forward to answer your questions:

  • Is adding remarketing user list audience is same as adding customer march user list?
    • Yes. You may also check this guide on how to add customer match user list.
  • how conversion tracker service is mapped to this ?because In old api sample there is usage of conversiontype and I’m looking similar.
  • what is the new api equivalent to the below code specifically conversiontracker service, create conversion type, getting and displaying conversion ids and trackers.
    • The answer to these two questions is this Add Conversion Based User List. You may try this on your end and please let us know if this works for you.

Kind regards,
Google Logo
Sherwin Vincent
Google Ads API Team
 


ref:_00D1U1174p._5004Q2d4Xta:ref

Ravindra Kumar

unread,
Aug 8, 2022, 6:23:45 AM8/8/22
to Google Ads API and AdWords API Forum
Hey, 

We are trying to change from below Adword API code (ref: https://developers.google.com/adwords/api/docs/samples/java/remarketing ) to new Google Ad API

// Display user lists.
    for (UserList userListResult : result.getValue()) {
      System.out.printf("User list with name '%s' and ID %d was added.%n",
          userListResult.getName(), userListResult.getId());

      // Display user list associated conversion code snippets.

      if (userListResult instanceof BasicUserList) {
        BasicUserList remarketingUserList = (BasicUserList) userListResult;
        for (UserListConversionType userListConversionType : remarketingUserList
            .getConversionTypes()) {
          ConversionTracker conversionTracker =
              conversionTrackers.get(userListConversionType.getId());
          System.out.printf(
              "Google global site tag:%n%s%n%n", conversionTracker.getGoogleGlobalSiteTag());
          System.out.printf(
              "Google event snippet:%n%s%n%n", conversionTracker.getGoogleEventSnippet());
        }
      }


We need the equivalent of this in the new Google Ad API. We have tried https://developers.google.com/google-ads/api/docs/samples/add-conversion-based-user-list, but could find the needed. Can you please help with this? 

Google Ads API Forum Advisor

unread,
Aug 8, 2022, 9:18:31 AM8/8/22
to ravindr...@gmail.com, adwor...@googlegroups.com
Hi Ravindra,

Thank you for the reply.

To further help you convert your Adwords API code to Google Ads API code, I would suggest referring to this document. If you have more clarifications regarding this, you may reach out to the Google Ads API Java Client Library issue tracker on github for assistance as they are more equipped for this matter.

Best regards,
Google Logo
Jinky
Google Ads API Team
 


ref:_00D1U1174p._5004Q2d4Xta:ref
Reply all
Reply to author
Forward
0 new messages