Adding mobile Ids to CrmBasedUserList through APIs isn't reflected into Google Ads site

108 views
Skip to first unread message

sejin jang

unread,
Dec 11, 2020, 3:01:22 AM12/11/20
to AdWords API and Google Ads API Forum
Hi there,

Below is an implemented Python code to upload Mobile Device Ids through API for remarketing.

But, customer List Id(6534339977) shows its size shows still 0 even though the number of uploaded mobile device Ids is much more than 1,000.

Would there be anyone who can help? 

* ATTACHED PYTHON SNIPPET
def send_google_mobile_device_id(df, country_code):
    """Adds a user list and populates it with hashed email addresses.
    Note: It may take several hours for the list to be populated with members. Email
    addresses must be associated with a Google account. For privacy purposes, the
    user list size will show as zero until the list has at least 1000 members. After
    that, the size will be rounded to the two most significant digits.
    """    
    def validate_idfa_format(idfa):
        idfa_splited = idfa.split('-')
        if [len(ele) for ele in idfa_splited] == [8, 4, 4, 4, 12]:
            return True
        else:
            return False
    
    # CREDENTIAL & AUTHENTICATE, with yaml
    gg_config = Config('cro', 'prod', False, True).get_read('googleads')
    
    with open("yaml", "w") as f:
        f.write(f"adwords:\n")
        f.write(f"   developer_token: {gg_config['developer_token']}\n")
        f.write(f"   client_id: {gg_config['client_id']}\n")
        f.write(f"   client_secret: {gg_config['client_secret']}\n")
        f.write(f"   refresh_token: {gg_config['refresh_token']}\n")
    f.close()
    client = adwords.AdWordsClient.LoadFromStorage('yaml')
    
    today = date.today()
    print("As of:", today)

    # CREATE A USER LIST
    cro_app_info = {"AOS": "com.devsisters.gb", "iOS": "963067330"}
    for os in ['AOS', 'iOS']:
        user_list = {
            'xsi_type': 'CrmBasedUserList',
            'name': f'Mobile Device ID({os}) as of {today}_{country_code}',
            'description': f'CRO Mobile Device IDs({os})',
            'uploadKeyType': 'MOBILE_ADVERTISING_ID',
            'appId': cro_app_info[os]
          }
        
        # Create an operation to add the user list.
        operations = [{
            'operator': 'ADD',
            'operand': user_list
        }]

        # Call User List Service
        user_list_service = client.GetService('AdwordsUserListService', 'v201809')
        result = user_list_service.mutate(operations)
        
        # Organize Mobile Device IDs from files
        user_list_id = result['value'][0]['id']
        members = [{'mobileId': mobile_id} for mobile_id in df["Mobile Device ID"].tolist() if validate_idfa_format(mobile_id) == True]

        # Send User List
        n = 0
        cut_off = int(4 * 1e5)
        for i in range(int(len(members)/cut_off) + 1):
            members_split = members[i * cut_off: (i + 1)*cut_off]
            n += len(members_split)

            # Form into JSON
            mutate_members_operation = {
              'operand': {
                  'userListId': user_list_id,
                  'membersList': members_split
              },
              'operator': 'ADD'
            }

            # Upload seeds through API
            response = user_list_service.mutateMembers([mutate_members_operation])
        
        if 'userLists' in response:
            print(f'a {n} number of User list with name {user_list["name"]} has been added.')

Google Ads API Forum Advisor Prod

unread,
Dec 14, 2020, 10:30:22 PM12/14/20
to sejin...@devsisters.com, adwor...@googlegroups.com
Hi Sejin,

You can enable logging for your Python client library by referring to this guide. That said, could you confirm if there were indeed no errors in your API requests?

If there weren't any errors, then you may note that it may take between 6 to 12 hours for a list to be populated with members. For more information on the other considerations when uploading audiences, you may refer here.

In addition to the above, I would recommend that you perform an AdwordsUserListService.get() request to verify the size that you uploaded.

If the period mentioned above has passed and you still notice issues between the sizes in the API and in the UI, then please also note that the Google Ads UI recently changed to use a different mechanism for estimating list size. These changes will be applied to the API in the near future.

Best regards,

Google Logo
Peter Laurence Napa Oliquino
Google Ads API Team
 


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