googleads / google-api-ads-ruby

Ad Manager SOAP API Client Libraries for Ruby
297 stars 227 forks source link

Multiple member identifiers of the same type for the same member? #141

Closed Tyler-Murphy closed 6 years ago

Tyler-Murphy commented 6 years ago

Is it possible to upload multiple member identifiers of the same type for the same member, as specified here?

We'd like to upload multiple email addresses and phone numbers in one operand. For example:

user_list_service.mutate_members([
  {
    operator: 'ADD',
    operand: {
      user_list_id: remarketing_list_id,
      members_list:[{
        hashed_email: '...',
        hashed_email: '...',
      }]
    }
  }
])

This isn't possible, since a hash can't have multiple values for the same symbol key. Changing the keys to strings (and allowing the same string key multiple times) also doesn't work:

AdsCommon::Errors::UnexpectedParametersError: AdsCommon::Errors::UnexpectedParametersError: ["hashed_email"]

Inspecting the generated XML (using mutate_members_to_xml) for a single email gives this:

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="https://adwords.google.com/api/adwords/rm/v201710" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns0="https://adwords.google.com/api/adwords/cm/v201710">
    <env:Header>
        <wsdl:RequestHeader xmlns="https://adwords.google.com/api/adwords/cm/v201710">
            <userAgent>rails (AwApi-Ruby/1.0.1, Common-Ruby/1.0.0, GoogleAdsSavon/1.0.3, ruby/2.3.5, HTTPI/2.4.2, httpclient)</userAgent>
            <developerToken>redacted</developerToken>
            <clientCustomerId>redacted</clientCustomerId>
        </wsdl:RequestHeader>
    </env:Header>
    <env:Body>
        <mutateMembers xmlns="https://adwords.google.com/api/adwords/rm/v201710">
            <operations>
                <ns0:operator>ADD</ns0:operator>
                <operand>
                    <userListId>redacted</userListId>
                    <membersList>
                        <hashedEmail>fcf5d104f0eca89941dc37102f8b594b38de42c4febabf77e2b583e55e1c4033</hashedEmail>
                    </membersList>
                </operand>
            </operations>
        </mutateMembers>
    </env:Body>
</env:Envelope>

It seems like we'd want the generated XML to include a <hashedEmail> tag for each email we want to upload. If string keys were supported, I think this would be possible.

mcloonan commented 6 years ago

See this example: https://github.com/googleads/google-api-ads-ruby/blob/master/adwords_api/examples/v201710/remarketing/add_crm_based_user_list.rb#L62

Instead of using one Hash with hashed_email repeated, make the array contain one hash per email, each with its own hashed_email field defined.

:members_list => [
  {:hashed_email => '...'},
  {:hashed_email => '...'},
  ...
]
Tyler-Murphy commented 6 years ago

Sorry, I simplified the example, and I left out some important details. Really, we want to send multiple emails, phone numbers, and addresses per hash. What you suggest is what we do right now, to send emails only.

Do you know if these are equivalent in all cases, in terms of the users who end up in the remarketing list?

:members_list => [
  {:hashed_email => '1'},
  {:hashed_phone_number => '1'}
]
:members_list => [
  {:hashed_email => '1', :hashed_phone_number => '1'}
]

We're under the impression that they're not equivalent, but if they are, we can send each person's information spread across multiple hashes.

mcloonan commented 6 years ago

Those are not equivalent. The former will create two separate Members, one with only an email address and the other with only a phone number. The latter will create a single Member, with both an email address and a phone number. You should be sure to update all known information on each member at the same time, in a single request.

Tyler-Murphy commented 6 years ago

Okay, that's what we figured. So is it impossible to send multiple emails, phone numbers, and addresses for a single user with this library in its current form?

mcloonan commented 6 years ago

Yes, a given user is treated as having only a single value for each of those fields. This is based on the design of the AdWords API, and it not specific functionality to the Ruby library.

Tyler-Murphy commented 6 years ago

That's doesn't appear to be how the AdWords API is designed, as indicated by both the web interface and the API documentation.

If you create a new customer list in the AdWords web interface, it makes a template available ("use a template"):

image

Here are the contents of the template:

Email,First Name,Last Name,Country,Zip,Email,Zip,Phone,Phone
test@gmail.com,john,smith,us,94016,,,1-800-888-8888,
test2@gmail.com,joanna,smith,cn,101300,test4@gmail.com,101500,,
test4@gmail.com,zoë,pérez,sg,WC2H 8LG,test6@gmail.com,,18008888899,1(800)888-8888

And in the AdWords API documentation for AdwordsUserListService.Member, it says:

Multiple member identifiers of the same type for the same member can be provided at the same time.

mcloonan commented 6 years ago

The API and the web interface are separate and the existence of functionality in one doesn't necessarily mean that the same functionality is shared in the other.

However, I do find that comment in the Member documentation confusing. If you look at the actual definition of the Member, there are no collections, which means there is no way to actually upload more than one. I imagine that comment is incorrect and I'm going to try to figure out what's going on there and potentially get that comment removed or updated to explain better what it means.

Tyler-Murphy commented 6 years ago

Okay, thanks! Have you heard anything?

mcloonan commented 6 years ago

Not yet. I've followed up again with the team that owns this.

This is not a bug with the Ruby library (it's doing what the WSDL says it can do, even if the documentation is confusing), so I'm going to have to close this out here on GitHub. However, if you want to keep up to date with progress on this issue, you can make a topic on our support forum (https://groups.google.com/forum/#!forum/adwords-api) and specifically request that your issue be assigned to me (Mike) and the team will route it so that I can follow up there.