Skip to main content
This guide demonstrates how to plug Mixpanel into an event collection pipeline by AWS Kafka. Once set up, your events will route to Mixpanel and be available in real-time for analytics. This approach is serverless and open-source, and takes ~5 minutes to set up. To read messages from a Kafka topic and send them to Mixpanel, you’ll need to use the confluent-kafka library for Kafka and the mixpanel library for Mixpanel.

Here’s a sample Python code snippet:

main.py
To run this code:
  1. Install Kafka and start a Kafka broker.
  2. Install necessary Python packages:
    • pip install confluent-kafka
    • pip install mixpanel
  3. Replace ‘YOUR_MIXPANEL_TOKEN’ with your actual Mixpanel token.
  4. Run the code.
Google has a great reference on best practices for handling both retryable and non-retryable errors.