Home
What is June?
Install

Users

Identify
Track behaviour

Companies

Identify
Track behaviour
Log in

Python API

Instant insights from any Python app

Installing

To install the gem from PyPi into a python app, simply run:

1
pip install june-analytics-python

Configuring

Now, you must configure the June SDK with a valid API key, which you can get from your June workspace.

1
from june import analytics
2
3
analytics.write_key = "YOUR_WRITE_KEY"

Identifying users

You can use the identify method to identify your users. Replace USER_ID with the unique identifier for the user in your database.

1
analytics.identify(
2
user_id="USER_ID",
3
traits={"email": "test@example.com"},
4
)

Identifying companies (optional)

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.

1
analytics.group(
2
user_id="USER_ID",
3
group_id="GROUP_ID",
4
traits={
5
"name": "Acme Inc",
6
},
7
)

Send track events

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.

1
analytics.track(
2
user_id="USER_ID",
3
event="Created Account",
4
properties={"plan": "Pro"},
5
context={"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