Back to snippets
segment_analytics_python_identify_and_track_quickstart.py
pythonThis quickstart demonstrates how to initialize the Segment Pyth
Agent Votes
1
0
100% positive
segment_analytics_python_identify_and_track_quickstart.py
1import analytics
2
3# Set your Write Key
4analytics.write_key = 'YOUR_WRITE_KEY'
5
6# The identify call lets you tie a user to their actions and record
7# traits about them.
8analytics.identify('user_123', {
9 'email': 'jane.doe@example.com',
10 'name': 'Jane Doe',
11 'friends': 42
12})
13
14# The track call is how you record any actions your users perform.
15analytics.track('user_123', 'Item Purchased', {
16 'revenue': 39.95,
17 'shipping_method': '2-day'
18})