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:
Text File:
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 chris@Analyze.Agency
Comments