Problem - While Creating the Customer Match List i am finding that Customer
List Is getting created but uploads is showing 0 and its not about time
because i've waited 2 - 3 days.*(Attaching Image)*
*[image: Screenshot from 2024-05-13 04-26-48.png]*
*CSV*
Email,Phone,First Name,Last Name,Country,Zip\n
x...@gmail.com,81-12-3456-7891,john,smith,us,94016\n
a...@gmail.com,81-12-3456-7891,joanna,smith,cn,101300\n
*RESPONSE, REQUEST*
Number of records read from CSV: 2
Processing record: x...@gmail.com
Processing record: a...@gmail.com
2024-05-13 04:23:05.570 INFO 8206 --- [ault-executor-0]
c.g.ads.googleads.lib.request.summary: SUCCESS REQUEST SUMMARY. Method:
google.ads.googleads.v16.services.UserListService/MutateUserLists,
Endpoint: googleads.googleapis.com:443, CustomerID: 5084430664, RequestID:
Jbr3MMpM8Zu_K5NKBQnOow, ResponseCode: OK, Fault: null.
Created Customer Match user list with resource name:
customers/5084430664/userLists/8658557609.
2024-05-13 04:23:22.230 INFO 8206 --- [ault-executor-2]
c.g.ads.googleads.lib.request.summary: SUCCESS REQUEST SUMMARY. Method:
google.ads.googleads.v16.services.GoogleAdsService/Search, Endpoint:
googleads.googleapis.com:443, CustomerID: 5084430664, RequestID:
QUQub7mmT6J2HEMrIQ5BwQ, ResponseCode: OK, Fault: null.
User list 'customers/5084430664/userLists/8658557609' has an estimated 0
users for Display and 0 users for Search.
*CODE(JAVA)*
public void addCustomerDataFromCSV(GoogleAdsClient googleAdsClient, long
customerId,
String filePath) {
try {
List customerRecords = CsvParser.parseCsv(filePath);
System.out.println("Number of records read from CSV: " +
customerRecords.size());
// Accumulate user data for all records
List userDataList = new ArrayList<>();
for (CustomerRecord record : customerRecords) {
System.out.println("Processing record: " + record.getEmail());
// Create user data for each record
UserData userData = createUserDataForRecord(record);
userDataList.add(userData);
}
// Create a single user list containing data from all records
createCustomerMatchUserList(googleAdsClient, customerId, userDataList);
} catch (IOException e) {
e.printStackTrace();
}
}
private UserData createUserDataForRecord(CustomerRecord record) {
// Inside your class or method
MessageDigest sha256Digest;
UserData.Builder userDataBuilder = UserData.newBuilder();
try {
sha256Digest = MessageDigest.getInstance("SHA-256");
// Add email as a UserIdentifier
UserIdentifier hashedEmailIdentifier = UserIdentifier.newBuilder()
.setHashedEmail(normalizeAndHashEmailAddress(sha256Digest,
record.getEmail()))
.build();
userDataBuilder.addUserIdentifiers(hashedEmailIdentifier);
// Add phone number as a UserIdentifier
if (record.getPhone() != null && !record.getPhone().isEmpty()) {
UserIdentifier hashedPhoneNumberIdentifier = UserIdentifier.newBuilder()
.setHashedPhoneNumber(normalizeAndHash(sha256Digest, record.getPhone(), true
))
.build();
userDataBuilder.addUserIdentifiers(hashedPhoneNumberIdentifier);
}
// Add other fields such as First Name, Last Name, Country, and Zip
OfflineUserAddressInfo addressInfo = OfflineUserAddressInfo.newBuilder()
.setHashedFirstName(normalizeAndHash(sha256Digest, record.getFirstName(),
true))
.setHashedLastName(normalizeAndHash(sha256Digest, record.getLastName(), true
))
.setCountryCode(record.getCountryCode())
.setPostalCode(record.getPostalCode())
.build();
UserIdentifier addressIdentifier = UserIdentifier.newBuilder()
.setAddressInfo(addressInfo)
.build();
userDataBuilder.addUserIdentifiers(addressIdentifier);
} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
// Handle the exception
e.printStackTrace();
}
return userDataBuilder.build();
}
private void createCustomerMatchUserList(GoogleAdsClient googleAdsClient, long
customerId, List userDataList) {
try (UserListServiceClient userListServiceClient =
googleAdsClient.getLatestVersion().createUserListServiceClient()) {
// Create the user list
UserList userList = UserList.newBuilder()
.setName("Customer Match list") // Provide a name for the list
.setDescription("A list of customers that originated from email addresses")
.setMembershipLifeSpan(30) // Set the membership lifespan as required
.setCrmBasedUserList(
CrmBasedUserListInfo.newBuilder()
.setUploadKeyType(CustomerMatchUploadKeyTypeEnum.CustomerMatchUploadKeyType.
CONTACT_INFO))
.build();
// Create the operation to add users
List operations = new ArrayList<>();
for (UserData userData : userDataList) {
operations.add(OfflineUserDataJobOperation.newBuilder
().setCreate(userData).build());
}
// Add the user list with all users
MutateUserListsResponse response = userListServiceClient.mutateUserLists(
Long.toString(customerId), ImmutableList.of(UserListOperation.newBuilder
().setCreate(userList).build()));
System.out.printf("Created Customer Match user list with resource name:
%s.%n",
response.getResults(0).getResourceName());
// Fetch the user list details
String userListResourceName =