Skip to main content
Gainsight Inc.

Gainsight PX Data Loader

Utility script to update Gainsight PX user, account and custom event data using the Gainsight PX REST API. Requires active Gainsight PX subscription and Gainsight PX API key (see below for details). An input file containing either user, account or custom event data in CSV format is used to update and optionally insert the corresponding records into Gainsight PX. If any errors are encountered during the process, they are logged to the screen and the process continues.

Install

Mac/OSX

Download script to your local computer using this link: gainsight-px-data-loader

Depends on python (>= v2.7) being installed locally and being present in the path. Most Macs already have Python installed.

There is an install script that will perform the remaining steps on OSX/Mac, download here: install.sh

Run install script:

bash ./install.sh

Windows

Download script to your local computer using this link: gainsight-px-data-loader

Python (>= 2.7.9) should be installed, see here if it is not: https://www.python.org/downloads/windows/

Install the "requests" library using pip

python -m pip install requests

Usage:

gainsight-px-data-loader [--insertMissing] [--verbose] [--dryRun] [-n startRow] [-l lastRow] config.json [USER|ACCOUNT|CUSTOM_EVENT] input.csv

  • Data type (second argument) should either be USER, ACCOUNT or CUSTOM_EVENT
  • If insertMissing is specified, will insert missing records. Default behavior is to update records that are found
  • insertMissing does not apply to custom events, events are always inserted
  • If verbose is specified, each operation is logged to stdout
  • If dryRun is specified, no data is changed, inputs are parsed
  • The -n and -l flags can be used to only process a portion of the file. For instance, -n 7 would start the processing on the seventh line of the file.

Mac Example For Updating User Data:

./gainsight-px-data-loader config.json USER users.csv

Windows Example For Updating User Data:

gainsight-px-data-loader config.json USER users.csv

User CSV File Example:

Account ID,Account Name,User ID,Job Title,Email,First Name,Last Name,Sign-Up Date UTC-MS,Role,Phone,Time Zone
3,HideMyStuff,tinylion155,BigData Engineer,corey.thomas@hideMyStuff.com,Corey,Thomas,1559696309000,Admin,(814)-853-6602,GMT+7

CSV details:

* Date values are specified as milliseconds since the Unix epoch

* String values can optionally be surrounded with double quotes to escape commas

Custom Event CSV File Example:

Account ID,User ID,Event Name,Event Date UTC-MS,Source,Terms,Category
3,tinylion155,Search,1560499354771,CSV,Example of search terms,Enterprise

Mac Example For Updating Custom Event Data:

./gainsight-px-data-loader  --verbose config.json CUSTOM_EVENT custom-events.csv

Download Examples

gainsight-px-data-loader-example.zip

Config File Example:
{
    "apiKey": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    "productKey": "AP-XXXXXXXXXXXX-2",
    "fieldMapping" : {
        "USER" : {
          "identifyId" : "User ID",
          "title" : "Job Title",
          "email": "Email",
  "firstName" : "First Name",
  "lastName" : "Last Name",
  "signUpDate" : "Sign-Up Date UTC-MS",
  "role" : "Role",
  "phone" : "Phone",
  "location.timeZone" : "Time Zone"
  
        },
        "ACCOUNT" : {
          "id" : "Account ID",
          "name" : "Account Name"
        },
        "CUSTOM_EVENT" :{
         "identifyId" : "User ID",
            "accountId" : "Account ID",
            "eventName" : "Event Name",
            "date" : "Event Date UTC-MS",
            "attributes.Source" : "Source",
            "attributes.Terms" : "Terms",
            "attributes.Category" : "Category"
        }
      }
}

Field Mapping Details:

  • apiKey: From the Gainsight PX Settings/REST API/New API Key screen
  • productKey: From the Gainsight PX Settings/Products screen (if you need to set more than one product key on a user or account, pass as an array: ['key1','key2'])
  • fieldMapping:
  • Specifies which Gainsight PX fields will be used as targets for the data in the input file.
  • The first field name (the key of the fieldMapping map) is the Gainsight PX name, the second (the value) is the name in the CSV input file.
  • The unique identifier field is required for both users, custom events (identifyId) and account (id)
  • To specify nested fields, use periods as separators (see location and customAttributes examples above)
  • Custom events: eventName and attributes correspond to the name and attributes usually passed in the Javascript API

Use Cases for PX Data Loader

  • Seeding data for users/account or custom event data.
  • Bringing in data from other databases/app.
  • Bringing in historical data from MixPanel/Pendo/Other Analytics apps. 
  • Was this article helpful?