googleads / google-ads-java

Google Ads API Client Library for Java
Apache License 2.0
171 stars 177 forks source link

Create a Remarketing user list (Audience) #662

Closed ravi9856 closed 2 years ago

ravi9856 commented 2 years ago

What is your question?

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

// 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 Client library. We have tried https://developers.google.com/google-ads/api/docs/samples/add-conversion-based-user-list, but could not find the needed. It would be great if we can get the link for the code equivalent for above code snippet, or the equivalent for "ConversionTracker" class, how to fetch and display conversion tracker IDs.

jradcliff commented 2 years ago

Hi,

In the AdWords API, conversion and remarketing actions were both represented as ConversionTracker objects. In the Google Ads API, those two actions are treated separately as ConversionAction and RemarketingAction.

You can get the global site tag, event, and tag snippets from each of those types. For example, here's a query to get the global site tag and event snippets for all of your conversion actions:

SELECT 
  conversion_action.id, 
  conversion_action.name, 
  conversion_action.origin, 
  conversion_action.type, 
  conversion_action.category, 
  conversion_action.status, 
  conversion_action.tag_snippets 
FROM conversion_action 

And here's a query to get the tag snippet from all of your remarketing actions:

SELECT 
  remarketing_action.id, 
  remarketing_action.name, 
  remarketing_action.tag_snippets 
FROM remarketing_action 

If that doesn't cover what you need, please let me know.

Thanks, Josh, Google Ads API Team