Analytics API
API reference for analytics endpoints — querying and ingesting events.
The analytics API provides endpoints for querying aggregated analytics data and ingesting events.
Get Overview
Section titled “Get Overview”Returns aggregate analytics for the specified time period.
GET /v1/analytics/overviewcurl -X GET "https://api.gopaylocal.com/v1/analytics/overview?period=7d" \ -H "Authorization: Bearer gpl_sk_live_xyz789"const res = await fetch( 'https://api.gopaylocal.com/v1/analytics/overview?period=7d', { headers: { 'Authorization': 'Bearer gpl_sk_live_xyz789' } });const { data } = await res.json();Query Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
period | string | 7d | Time period: 1d, 7d, 30d, 90d, 365d |
campaignId | string | — | Filter by campaign ID |
productId | string | — | Filter 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 } ] }}Get By Country
Section titled “Get By Country”Returns analytics broken down by country.
GET /v1/analytics/by-countrycurl -X GET "https://api.gopaylocal.com/v1/analytics/by-country?period=30d" \ -H "Authorization: Bearer gpl_sk_live_xyz789"const res = await fetch( 'https://api.gopaylocal.com/v1/analytics/by-country?period=30d', { headers: { 'Authorization': 'Bearer gpl_sk_live_xyz789' } });const { data } = await res.json();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 } ]}Get By Campaign
Section titled “Get By Campaign”Returns analytics broken down by campaign.
GET /v1/analytics/by-campaignResponse:
{ "data": [ { "campaignId": "camp_abc123", "campaignName": "Pro Plan PPP", "impressions": 8200, "clicks": 2624, "copies": 2300, "redemptions": 312, "redemptionRate": 3.80 } ]}Ingest Events
Section titled “Ingest Events”Send analytics events to the GoPayLocal events endpoint. This is used internally by the banner script.
POST /v1/eventscurl -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:
| Field | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Event type: impression, click, copy, dismiss |
campaignId | string | Yes | Campaign ID |
country | string | Yes | ISO country code |
discount | number | No | Discount percentage |
code | string | No | Coupon code (for copy events) |
timestamp | number | No | Unix timestamp in ms (defaults to server time) |
Response: 202 Accepted
Data Retention
Section titled “Data Retention”| Plan | Retention |
|---|---|
| Free | 7 days |
| Pro | 90 days |
| Business | 365 days |
| Enterprise | 365 days |
Data beyond the retention period is automatically deleted.