Getting started with the Product Insights SDK for Python

[This topic is pre-release documentation and is subject to change.]

This tutorial will guide you through the process of using a Product Insights ingestion token and the Product Insights SDK for your existing Python application. You'll start seeing signals in your portal in five minutes or sooner.

For this example, picture the following scenario: you work at a car manufacturing company, and the company has just released a new car. You want to know how the car is performing, your users' demographics, and their driving habits. Product Insight allows you to achieve these goals by sending real time signals and generating valuable insights in just a few simple steps.


  • Python 2.7 or 3+
  • Ingestion key (see below for instructions on how to obtain)

Get an ingestion key from Product Insights portal

  1. From the home screen, select your team from the left panel. If you do not already have a team, refer to Create a team.
  2. Add a new project to your team by selecting the + New Project button from the top right corner.
  3. Type in a project name in the Name field and any other text for Description. Select Create to commit the update.
  4. Once your project is created, select the project.
  5. Select Settings under your project. Your ingestion key is available under Ingestion Key.


Leave this tab open in your web browser, or copy the key to a clipboard because you will need to use it later.

Integrate the Product Insights SDK into your Python project

  1. Download the Product Insights Python SDK.

  2. Add the SDK to your project's site packages. This can either be done permanently or at runtime or permanently added to your site-packages directory.

    • Permanently: With the specific Python interpreter you want to use activated, cd to your project directory. Then, run python -m easy_install pi_analytics-x.y.z.egg

    • At runtime: Put the following code block before any pi_analytics import:

        import sys


    Replace the x.y.z with the version number found in the decompressed file.

  3. Initialize the SDK:

    from pi_analytics, import PIAnalytics, Signal
    from product_insights, import LogManager
    from datetime import datetime
    pia = PIAnalytics('your-ingestion-key')
  4. Track signals:

    • Do a simple track signals call:

      sig = Signal('car_information')
    • Both indexing and set_property() are allowed:['engine_start'] = True['car_model'] = 'Star Car'
      sig.set_property('model_year', datetime.fromtimestamp(1565631527))
      sig.set_property('rpm', 3000)
      sig.set_property('temperature', 74.3)

    The following types are supported for custom signal properties:

    • str
    • float
    • int
    • datetime
    • UUID
    • bool
  5. Teardown the SDK when the application closes to ensure all signals currently in the queue are sent: