How To Insert Backend Events Into Mixpanel.
Architecture to send backend events into Mixpanel.

How To Insert Backend Events Into Mixpanel.

Online Scenario: Let's say a t-shirt-selling e-commerce store has Mixpanel integrated into its website. When someone buys a t-shirt; the following event is sent to Mixpanel.

Event Name: t-shirt Purchased

Event Properties: Color = Blue, Size = Medium, Cost = 95

Offline Purchases: The e-commerce store becomes the official t-shirt-selling partner of a musical tour that happens all over the world. During the tour, the e-commerce store sells t-shirts to tour fans in multiple physical locations. Whenever a sale is made it is recorded on a text file.

Analytical Question: The CEO of the e-commerce company wants to know how many t-shirts were sold totally including online and offline. What was the most popular t-shirt color sold? What size t-shirt had the highest demand?

Problem: Some percentage of the sales happened offline therefore the t-shirt Purchased events for offline purchases were not sent into Mixpanel.

Solution: Given that a significant number of sales happened offline one would need to insert/import them into Mixpanel to provide consolidated answers to CEO's questions.




Solution Architecture.

No alt text provided for this image
Architecture to send backend events into Mixpanel.



The text file looks like the following.

No alt text provided for this image




Python Script.

# Install Mixpanel Module
pip install mixpanel_utils


# Import mixpanel_utils module
from mixpanel_utils import MixpanelUtils        



if __name__ == '__main__':

  # Plug in credentials    
  credentials = {'API_secret': 'get from Mixpanel','token': 'get from Mixpanel'}

  i = MixpanelUtils(credentials['API_secret'],credentials['token'])

  # Send events to Mixpanel 
  i.import_events('https://From-The-Text-File-Source.txt', timezone_offset=0)
                




Note: If you need help with Product Analytics, Data Engineering / Visualization, or Ad Analytics please feel free to reach me at [email protected]

Hal Zeitlin

We build custom Webflow sites for B2B SaaS @ Candid Leap | Enterprise Webflow Partner | I'd love for you to try our bagels too

1y

You make it look simple!

Like
Reply

To view or add a comment, sign in

Insights from the community

Others also viewed

Explore topics