1pip install june-analytics-python
To install the gem from PyPi into a python app, simply run:
1pip install june-analytics-python
Now, you must configure the June SDK with a valid API key, which you can get from your June workspace.
1from june import analytics 2 3analytics.write_key = "YOUR_WRITE_KEY"
You can use the identify
method to identify your users. Replace USER_ID
with the unique identifier for the user in your database.
1analytics.identify( 2user_id="USER_ID", 3traits={"email": "test@example.com"}, 4)
You can use the group
method to identify your companies. Replace GROUP_ID
and USER_ID
with the unique identifier for the company and user in your database.
1analytics.group( 2user_id="USER_ID", 3group_id="GROUP_ID", 4traits={ 5"name": "Acme Inc", 6}, 7)
In order to track user behaviour, you can use the track
method.
Note: If you're identifying companies, you should pass the groupId
in the track context, as shown in the example below. Replace GROUP_ID
and USER_ID
with the unique identifier for the company and user in your database.
1analytics.track( 2user_id="USER_ID", 3event="Created Account", 4properties={"plan": "Pro"}, 5context={"groupId": "GROUP_ID"}, 6)
Our SDK is based on Segment's SDK. You can find more documentation here: https://segment.com/docs/connections/sources/catalog/libraries/server/python