Skip to content

Commit a59151a

Browse files
authored
Merge pull request #233 from 18F/add_v2_migration_docs
Add API v1 -> v2 migration docs to README
2 parents c50436d + 7846c49 commit a59151a

File tree

1 file changed

+73
-9
lines changed

1 file changed

+73
-9
lines changed

README.md

Lines changed: 73 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,41 +50,105 @@ is configured to write to the same database and run with the `--write-to-databas
5050

5151
# Using the API
5252

53+
Full API docs can be found here: https://open.gsa.gov/api/dap/
54+
55+
## Environments
56+
57+
The base URLs for the 3 API envrionments:
58+
- development: https://api.gsa.gov/analytics/dap/develop/
59+
- staging: https://api.gsa.gov/analytics/dap/staging/
60+
- production: https://api.gsa.gov/analytics/dap/
61+
62+
## Overview
63+
5364
The Analytics API exposes 3 API endpoints:
54-
include version in the request, ie `/v2/`
5565

56-
- `/reports/:report_name/data`
57-
- `/agencies/:agency_name/reports/:reportName/data`
58-
- `/domain/:domain/reports/:reportName/data`
66+
- `/v{api_version}/reports/{report_name}/data`
67+
- `/v{api_version}/agencies/{agency_name}/reports/{report_name}/data`
68+
- `/v{api_version}/domain/{domain}/reports/{report_name}/data`
5969

60-
Each endpoint renders a JSON array with the most recent 1000 records the
70+
Each endpoint renders a JSON array with the most recent 1000 records that the
6171
Analytics Reporter has generated for the given agency and report. If no records
6272
are found, an empty array is returned.
6373

6474
Records are sorted according to the associated date.
6575

66-
##### Limit
76+
### Limit query parameter
6777

6878
If a different number of records is desired, the `limit` query parameter can be
6979
set to specify the desired number of records.
7080

7181
```
72-
/reports/realtime/data?limit=500
82+
/v2/reports/realtime/data?limit=500
7383
```
7484

7585
The maximum number of records that can be rendered for any given request is
7686
10,000.
7787

78-
##### Page
88+
### Page query parameter
7989

8090
If the desired record does not appear for the current request, the `page` query
8191
parameter can be used to get the next series of data points. Since the data is
8292
ordered by date, this parameter effectively allows older data to be queried.
8393

8494
```
85-
/reports/realtime/data?page=2
95+
/v2/reports/realtime/data?page=2
8696
```
8797

98+
## Migrating from API V1 to API V2
99+
100+
### Background
101+
102+
Analytics API V1 returns data from Google Analytics V3, also known as Universal
103+
Analytics (UA).
104+
105+
Google is retiring UA and is encouraging users to move to their new
106+
version Google Analytics V4 (GA4) in 2024.
107+
108+
Analytics API V2 returns data from GA4.
109+
110+
### Migration details
111+
112+
#### Requests
113+
114+
The Analytics API endpoints are the same between V1 and V2, the only difference
115+
for API requests is the API version string.
116+
117+
#### Responses
118+
119+
Response data is slightly different in Analytics API V2. This change is due to
120+
the data provided by Google Analytics. Some data fields were retired in GA4, and
121+
some other useful data fields were added. The changes follow:
122+
123+
##### Deprecated fields
124+
125+
- browser_version
126+
- has_social_referral
127+
- exits
128+
- exit_page
129+
130+
##### New fields
131+
132+
###### bounce_rate
133+
134+
The percentage of sessions that were not engaged. GA4 defines engaged as a
135+
session that lasts longer than 10 seconds or has multiple pageviews.
136+
137+
###### file_name
138+
139+
The page path of a downloaded file.
140+
141+
###### language_code
142+
143+
The ISO639 language setting of the user's device. e.g. 'en-us'
144+
145+
###### session_default_channel_group
146+
147+
An enum which describes the session. Possible values:
148+
149+
'Direct', 'Organic Search', 'Paid Social', 'Organic Social', 'Email',
150+
'Affiliates', 'Referral', 'Paid Search', 'Video', and 'Display'
151+
88152
# Running the Tests
89153

90154
The Analytics API application is backed by a test suite that uses

0 commit comments

Comments
 (0)