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 | |
| required, value: | String | The type of payload |
| optional if | String | A unique id for the user in your database |
| optional | Object | A dictionary of traits for a user, like |
Node.Js
const axios = require('axios');
// Identify object
identify = {
type: "identify",
userId: "1",
traits: {
name: "Elon Musk",
email: "[email protected]",
plan: "pro",
logins: 1
}
}
// JSON format expected
const options = {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: 'Basic <YOUR API KEY>',
},
};
const url = 'https://api.june.so/api/identify';
// Send event to June
axios.post(url, identify, options);
Python
identify_payload = {
"type": "identify",
"userId": "1",
"traits": {
"name": "Elon Musk",
"email": "[email protected]",
"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
Identify a company
Field | Type | Description | |
| required, value: | String | The type of payload |
| required | String | A unique id for the company in your database |
| required | String | A unique id for the user in your database |
| optional | Object | A dictionary of traits for a user, like |
Node.Js
const axios = require('axios');
// Group object
group = {
type: "group",
groupId: "A",
userId: "1",
traits: {
name: "SpaceX"
}
}
// JSON format expected
const options = {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: 'Basic <YOUR API KEY>',
},
};
const url = 'https://api.june.so/api/group';
// Send event to June
axios.post(url, group, options);
Python
group_payload = {
"type": "group",
"groupId": "A",
"userId": "1",
"traits": {
"name": "SpaceX"
}
}
group_url = "https://api.june.so/api/group"
api_key = "secret_api_key" # from the June settings page
response = requests.post(
group_url,
json=group_payload,
headers={'Authorization': f'Basic {api_key}'}
)
assert response.status_code == 200
Track an event for a user
Field | Type | Description | |
| required, value: | String | The type of payload |
| required | String | The name of the event that a user performed |
| optional if | String | A unique id for the user in your database |
| required, ISO format with timezone set to UTC | String | The time at which the user performed the event |
| optional if | String | The email for the user who performed this event |
| optional | Object | A dictionary of properties for the event, like |
| optional | Object | Addtional context for the event |
Node.Js
const axios = require('axios');
// Event object
const event = {
type: 'track',
event: 'Dashboard Loaded',
userId: '1',
timestamp: '2021-02-24T01:19:38.931Z',
email: '[email protected]',
};
// JSON format expected
const options = {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: 'Basic <YOUR API KEY>',
},
};
const url = 'https://api.june.so/api/track';
// Send event to June
axios.post(url, event, options);
Python
track_payload = {
"type": "track",
"event": "Registered",
"userId": "1",
"timestamp": "2021-02-24T01:19:38.931Z",
"email": "[email protected]",
"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