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.')

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/f39eeaa2-8dad-43e4-83a1-c7750d949e45n%40googlegroups.com.

Reply via email to