API Reference
Analytics (API)
Read your web analytics programmatically through the Pxl API. Get insights from you analytics through the following API requests. Related guide: Analytics.
This feature is available on all plans.
The insight object
recent: number
The number of page views that occured within the last 30 minutes.
total: number
The total number of page views that occured within the specified period.
unique: number
The number of unique page views that occured within the specified period.
grouped: object
An array of objects containing the total page views and unique page views for each consecutive day (or hour) within the specified period.
properties: object
An object containing the total page views and unique page views of each distinct property value, grouped by property category (city, country, device, browser) within the specified period.
List insight
To return all insight associated with your organisation, you will make a GET request.
GET https://api.pxl.to/api/v1/insight
Parameters
datefrom: _string
The start date of the range for which data will be returned, formatted as YYYY-MM-DD. Defaults to 7 days before the current date.
dateto: _string
The end date of the range for which data will be returned, formatted as YYYY-MM-DD. Defaults as the current date.
timezone: string
The timezone for which any returned data will be offset. Defaults to UTC.
link: string
The specific link for which analytics data will be returned.
domain: string
The specific domain for which analytics data will be returned.
device: string
The device type for which analytics data will be returned.
browser: string
The specific browser for which analytics data will be returned.
OS: string
The specific OS for which analytics data will be returned.
country: string
The specific country for which analytics data will be returned, formatted as an ISO 3166 2-digit code.
city: string
The specific city for which analytics data will be returned.
medium: string
The specific medium for which analytics data will be returned.
source: string
The specific source for which analytics data will be returned.
Returns
Returns an insight object representing the analytics performance of every link within your organisation.
Request
An example CURL request:
curl -X GET --compressed "https://api.pxl.to/api/v1/insight?timezone=Europe/London&country=US&date_from=2023-06-16&date_to=2023-06-22" \
-H "Accept-Encoding: gzip" \
-H "Authorization: Bearer <YOUR_ACCESS_TOKEN>" \
Response
An example JSON response:
{
"data": {
"unique": 91,
"total": 108,
"recent": 4,
"grouped": [
{
"t": "2023-06-16",
"visits": 7,
"hits": 8
},
{
"t": "2023-06-17",
"visits": 11,
"hits": 12
},
{
"t": "2023-06-18",
"visits": 10,
"hits": 11
},
{
"t": "2023-06-19",
"visits": 11,
"hits": 12
},
{
"t": "2023-06-20",
"visits": 15,
"hits": 16
},
{
"t": "2023-06-21",
"visits": 14,
"hits": 16
},
{
"t": "2023-06-22",
"visits": 23,
"hits": 33
}
],
"properties": {
"source": [
{
"type": "banner",
"visits": 52,
"hits": 52
},
{
"type": "app",
"visits": 18,
"hits": 23
}
],
"browser": [
{
"type": "Chrome",
"visits": 74,
"hits": 89
},
{
"type": "Edge",
"visits": 4,
"hits": 6
},
{
"type": "Firefox",
"visits": 3,
"hits": 3
}
],
"link": [
{
"type": "pxl.to/example",
"visits": 52,
"hits": 52
},
{
"type": "pxl.to/example/2",
"visits": 13,
"hits": 15
}
],
"country": [
{
"type": "US",
"visits": 91,
"hits": 108
}
],
"city": [
{
"type": "Charlotte",
"visits": 27,
"hits": 33
},
{
"type": "Boardman",
"visits": 6,
"hits": 6
},
{
"type": "Los Angeles",
"visits": 5,
"hits": 5
},
{
"type": "San Jose",
"visits": 3,
"hits": 4
},
{
"type": "Dallas",
"visits": 3,
"hits": 3
}
],
"device": [
{
"type": "desktop",
"visits": 87,
"hits": 103
},
{
"type": "mobile",
"visits": 3,
"hits": 4
},
{
"type": "tablet",
"visits": 1,
"hits": 1
}
],
"domain": [
{
"type": "pxl.to",
"visits": 78,
"hits": 93
}
],
"medium": [
{
"type": "Click",
"visits": 91,
"hits": 108
}
],
"OS": [
{
"type": "Windows",
"visits": 39,
"hits": 47
},
{
"type": "Mac OS",
"visits": 19,
"hits": 23
},
{
"type": "Linux",
"visits": 17,
"hits": 21
}
]
}
}
}