Docs
Tracking
Snowflake

Snowflake

This is a step-by-step guide to get your Snowflake Warehouse Connector up and running.

IP Allowed List

If you are using Snowflake Network policy (opens in a new tab) to restrict access to your instance, you might need to add the following IP addresses to the allowed list.

34.31.112.201
34.147.68.192
35.184.21.33
35.225.176.74
35.204.164.122
35.204.177.251

1. Connect to your Warehouse

To connect to your warehouse, complete the following steps:

  1. Navigate to Project Settings, then select Warehouse Sources.

  2. Click on + Add Connection and select Snowflake.

  3. You should see a new page to create your snowflake connector. In the first view, fill out the following fields before clicking Next:

    • Snowflake Account Name / URL
    • Username
    • Role
    • Authentication Type. We support both Password and Key Pair. Ensure that the corresponding commands have been successfully completed in your Snowflake instance.
      • For Password authentication:
        • Fill out the password field.
        • Copy the commands and run them within your Snowflake instance.
        • Be sure to fill out the password field in your command.
      • For Key Pair authentication:
        • Mixpanel will generate a secure key pair for your source per the Snowflake requirements.
        • The private key will be encrypted and stored securely, and used only when we need to communicate with your Snowflake instance.
        • Public key can be found in the suggested SQL to create your user.
  4. In the second view, you can click Create Source after completing the following:

    • Warehouse

      • Enter the name of your warehouse (default value: MIXPANEL_IMPORT_WAREHOUSE).

      • We recommend creating a separate warehouse for Mixpanel, and ensuring that Mixpanel has the appropriate role permissions to access it.

      • Run the commands below in Snowflake.

        CREATE WAREHOUSE MIXPANEL_IMPORT_WAREHOUSE WITH WAREHOUSE_SIZE = XSMALL AUTO_SUSPEND = 60 AUTO_RESUME = TRUE INITIALLY_SUSPENDED = FALSE;
        GRANT USAGE ON WAREHOUSE MIXPANEL_IMPORT_WAREHOUSE TO ROLE MIXPANEL_IMPORT_ROLE;
        GRANT OPERATE ON WAREHOUSE MIXPANEL_IMPORT_WAREHOUSE TO ROLE MIXPANEL_IMPORT_ROLE;
        GRANT MONITOR ON WAREHOUSE MIXPANEL_IMPORT_WAREHOUSE TO ROLE MIXPANEL_IMPORT_ROLE; 
    • Storage Integration

      • This is required because Mixpanel will export the query results into a GCS bucket.
      • Default value: MIXPANEL_IMPORT_STORAGE_INTEGRATION
      CREATE STORAGE INTEGRATION MIXPANEL_IMPORT_STORAGE_INTEGRATION
        TYPE = EXTERNAL_STAGE
        STORAGE_PROVIDER = 'GCS'
        ENABLED = TRUE
        STORAGE_ALLOWED_LOCATIONS = ("gcs://mixpanel-2946576-ca470bce1e1ed2ec");
      GRANT USAGE ON INTEGRATION MIXPANEL_IMPORT_STORAGE_INTEGRATION TO MIXPANEL_IMPORT_ROLE; 
    • Database (optional)

      • Enter the name of the database you want to grant permission to.
      • By default, we request read-only access.
      • Mixpanel does not store the access information. However, you can choose to provide more granular access if you desire.
      GRANT USAGE ON DATABASE "<your_data_base>" TO ROLE MIXPANEL_IMPORT_ROLE;
      GRANT USAGE ON ALL SCHEMAS IN DATABASE "<your_data_base>" TO ROLE MIXPANEL_IMPORT_ROLE;
      GRANT SELECT ON ALL TABLES IN DATABASE "<your_data_base>" TO ROLE MIXPANEL_IMPORT_ROLE;
      GRANT SELECT ON ALL VIEWS IN DATABASE "<your_data_base>" TO ROLE MIXPANEL_IMPORT_ROLE;

2. Format Data for Mixpanel Ingestion

To import data from a warehouse directly, make sure the tables are formatted correctly.

Each column in the table will be mapped as a property on the event.

Read more about best practices for tracking Events and Properties in Mixpanel here (opens in a new tab).

The following columns are required:

  • Event Time
  • Distinct ID
  • Insert ID
    • This is an optional field, but we recommend it as a best practice in case duplicate events need to be reconciled.
  • Insert Time
    • We expect this to be a monotonically increasing TIMESTAMP_NTZ. We use this as a water mark to figure out which events are new and ingest them.
  • Event Name
    • You can specify the column that has this value.
    • Alternatively, you can specify a static value during creation.

3. Send Events

Once you have created a warehouse source, follow the below steps to send events into Mixpanel.

  1. Go to Project Settings > Warehouse Data.
  2. Click on + Add Warehouse Event.
  3. Select Snowflake as the source from the dropdown.
  4. Select the database and schema.
  5. Select the table that contains your events.
  6. Specify the Event Name:
    • You can specify the column which has the event name.
    • OR You can specify the event name for all rows in the table.
  7. Specify the Event Time:
    • This is the time the event occurred.
  8. Select the column to be used for Insert ID.
  9. Identity Management:
    • If your project has Simplified ID Merge, the warehouse connector will prompt you to map the $device_id and $user_id properties to columns in your table during setup. For more information on how we map those fields to the resulting distinct id, refer to our documentation here (opens in a new tab).
    • If your project has Original ID Merge, the warehouse connector will prompt you to map the Distinct ID column. This column represents the entity to which the events belong; it could be a user or a device. If you want to map two entities together you have to additionally call either $identify, $merge, $alias functions, along with their corresponding properties. For more information, refer to our documentation here (opens in a new tab).
  10. Check the preview to ensure that everything looks correct, and then create the event.