Skip to content

Analytics API

API reference for analytics endpoints — querying and ingesting events.

The analytics API provides endpoints for querying aggregated analytics data and ingesting events.

Returns aggregate analytics for the specified time period.

GET /v1/analytics/overview
Terminal window
curl -X GET "https://api.gopaylocal.com/v1/analytics/overview?period=7d" \
-H "Authorization: Bearer gpl_sk_live_xyz789"

Query Parameters:

ParameterTypeDefaultDescription
periodstring7dTime period: 1d, 7d, 30d, 90d, 365d
campaignIdstringFilter by campaign ID
productIdstringFilter by product ID

Response:

{
"data": {
"impressions": 10230,
"clicks": 3274,
"copies": 2891,
"redemptions": 423,
"period": "7d",
"timeseries": [
{ "date": "2025-01-15", "impressions": 1450, "clicks": 468, "copies": 413, "redemptions": 61 },
{ "date": "2025-01-16", "impressions": 1380, "clicks": 442, "copies": 390, "redemptions": 58 }
]
}
}

Returns analytics broken down by country.

GET /v1/analytics/by-country
Terminal window
curl -X GET "https://api.gopaylocal.com/v1/analytics/by-country?period=30d" \
-H "Authorization: Bearer gpl_sk_live_xyz789"

Response:

{
"data": [
{
"country": "IN",
"countryName": "India",
"impressions": 3200,
"clicks": 890,
"copies": 780,
"redemptions": 134,
"redemptionRate": 4.19
},
{
"country": "BR",
"countryName": "Brazil",
"impressions": 1800,
"clicks": 420,
"copies": 370,
"redemptions": 63,
"redemptionRate": 3.50
}
]
}

Returns analytics broken down by campaign.

GET /v1/analytics/by-campaign

Response:

{
"data": [
{
"campaignId": "camp_abc123",
"campaignName": "Pro Plan PPP",
"impressions": 8200,
"clicks": 2624,
"copies": 2300,
"redemptions": 312,
"redemptionRate": 3.80
}
]
}

Send analytics events to the GoPayLocal events endpoint. This is used internally by the banner script.

POST /v1/events
Terminal window
curl -X POST https://api.gopaylocal.com/v1/events \
-H "Content-Type: application/json" \
-d '{
"type": "impression",
"campaignId": "camp_abc123",
"country": "IN",
"discount": 30,
"timestamp": 1705312200000
}'

Request Body:

FieldTypeRequiredDescription
typestringYesEvent type: impression, click, copy, dismiss
campaignIdstringYesCampaign ID
countrystringYesISO country code
discountnumberNoDiscount percentage
codestringNoCoupon code (for copy events)
timestampnumberNoUnix timestamp in ms (defaults to server time)

Response: 202 Accepted

PlanRetention
Free7 days
Pro90 days
Business365 days
Enterprise365 days

Data beyond the retention period is automatically deleted.