Import user data with a CSV file upload
You can use a CSV upload for larger, one-time imports of user data such as historic push tokens or email addresses. For this, you'll use the multi (CSV) API call.
Once uploaded and processed, this information will be stored in Leanplum and available on our platform for targeting and segmenting users.
Note: Once the import is finished, it may take up to 15 minutes to be able to use the data in your segmentation.
Steps To Upload User Data
Follow the below steps to upload your user attribute and event data.
Step 1: Prepare the CSV file
Save your file in regular CSV format without any encoding.
Depending on what type of data you want to import, you'll need to include different parameter fields in your file. The upload will fail if the CSV is formatted incorrectly.
The header row of your file will include the parameter fields for the data you're importing (such as user attributes), separated by commas. Use a dot to indicate nested parameters. For example:
userId,userAttributes.Gender,userAttributes.Age
user1,Male,25
user2,Female,37
Here are the various types of info you can import — click each to learn how to format the CSV.
For more about file formatting, see Prepare a CSV file to import user data.
Step 2: Upload the CSV to your Leanplum Google Bucket
Leanplum Technical Support will provide you with access to your Leanplum Google Bucket. You'll need to link the appropriate Google Bucket folder in your API call path.
G Suite or Google account is required
To be able to upload the file in your assigned bucket you will need either a G Suite or a regular Google account.
Step 3: Construct the API call
Development Key Required
For security reasons CSV imports are allowed only with the Development key for the app where you are uploading the data.
The API method for CSV upload is multi (CSV). You will need to pass different values to the defaultAction
parameter depending on what kind of data you are uploading.
https://www.leanplum.com/api?action=multi&apiVersion=1.0.6&appId={App_ID}&clientKey={Dev_Key}&defaultAction={leanplum_api_action}&gcsBucket={bucket_name}&file={path/file_name}&createJob=true
- User Attributes: defaultAction=setUserAttributes
- Device Attributes: defaultAction=setDeviceAttributes
- Events: defaultAction=track
- Historical Events: defaultAction=setUserAttributes
- Email Unsubscribe: defaultAction=setUserAttributes
Step 4: Monitor the uploading status
You can use the getMultiResults API call to check the status of the uploading job.
Your response will be one of these:
- Pending. The job is still waiting in the queue and has not started processing yet.
- Running. The job is currently being processed.
- Finished. The job has finished. (This means the file has processed, not necessarily that the upload was 100% successful.)
- Failed. The job failed before it could execute. The most common reason is Leanplum's backend could not read the file, perhaps due to file permissions or the file not being public.
To perform the getMultiResults
call, you'll need the original multi
call ID, found here:
Updated almost 3 years ago