Currently, June can only generate reports on event data that it receives starting on the day you connect Segment. If you have access to old event data for a Segment source, you can easily send it to June by:

  • Getting an API key for the Segment source from the June settings page:

  • Sending a request to identify a user

  • Sending a request to track an event for a user

Here are some sample payloads and code that you can check out:

Identify a user

Field

Type

Description

type

required, value: identify

String

The type of payload

userId

optional if anonymousId is set instead

String

A unique id for the user in your database

traits

optional

Object

A dictionary of traits for a user, like email or name

identify_payload = {
"type": "identify",
"userId": "1",
"traits": {
"name": "Elon Musk",
"email": "elon@tesla.com",
"plan": "pro",
"logins": 1
}
}

identify_url = "https://api.june.so/api/identify"
api_key = "secret_api_key" # from the June settings page

response = requests.post(
identify_url,
json=identify_payload,
headers={'Authorization': f'Basic {api_key}'}
)

assert response.status_code == 200

Track an event for a user

Field

Type

Description

type

required, value: track

String

The type of payload

event

required

String

The name of the event that a user performed

userId

optional if anonymousId is set instead

String

A unique id for the user in your database

timestamp

required, ISO format with timezone set to UTC

String

The time at which the user performed the event

email

optional if anonymousId is set

String

The email for the user who performed this event

properties

optional

Object

A dictionary of properties for the event, like revenue

track_payload = {
"type": "track",
"event": "Registered",
"userId": "1",
"timestamp": "2021-02-24T01:19:38.931Z",
"email": "elon@tesla.com",
"properties": {
"plan": "pro"
}
}

track_url = "https://api.june.so/api/track"
api_key = "secret_api_key" # from the June settings page

response = requests.post(
track_url,
json=track_payload,
headers={'Authorization': f'Basic {api_key}'}
)

assert response.status_code == 200

See also: Importing historical events to June.so from BigQuery

Did this answer your question?