# Google Analytics: How to migrate from Reporting API v3 to v4

**URL:** <https://community.cdata.com/t/google-analytics-how-to-migrate-from-reporting-api-v3-to-v4/772>\
**Category:** CData Virtuality \[Archived\]\
**Tags:** article, cdata-virtuality\
**Created:** [June 10, 2024, 4:36pm UTC](https://community.cdata.com/t/google-analytics-how-to-migrate-from-reporting-api-v3-to-v4/772 "2024-06-10T16:36:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@anonymous](https://community.cdata.com/u/anonymous)\
**Post date:** [June 10, 2024, 4:36pm UTC](https://community.cdata.com/t/google-analytics-how-to-migrate-from-reporting-api-v3-to-v4/772/1 "2024-06-10T16:36:16Z")

</div>

The Google Analytics connector comes with two procedures for generating reports:

- get: Uses the Reporting API v3
- getV4:&nbsp;Uses the Reporting API v4

Both procedures and APIs are largely compatible with each other, but switching from v3 to v4 still requires a few changes.

This is an example call using the get procedure and therefore API v3:

```auto
SELECT PARSEDATE(a.date, 'yyyyMMdd') AS "date", CAST(a.users AS integer) AS users, CAST(a.newUsers AS integer) AS newUsers, CAST(a.percentNewSessions AS float) AS percentNewSessionsFROM ( EXEC google_analytics_src.get( profile => 68903984, startDate => '2017-04-01', endDate => '2017-04-02', metrics => 'users,newUsers,percentNewSessions', dimensions => 'date', samplingLevel => 'Higher_Precision', sort => 'users' )) a

```

Switching this query to API v4 involves:

1. Changing the procedure from “get” to “getV4”
2. Renaming the “profile” parameter to “viewId”
3. If you use the “samplingLevel” parameter, the values have changed. Please see&nbsp;[Google’s migration guide](https://developers.google.com/analytics/devguides/reporting/core/v4/migration#sampling_level)&nbsp;for a mapping of old to new values.

After those changes, the call to v4 looks like this:

```auto
SELECT PARSEDATE(a.date, 'yyyyMMdd') AS "date", CAST(a.users AS integer) AS users, CAST(a.newUsers AS integer) AS newUsers, CAST(a.percentNewSessions AS float) AS percentNewSessionsFROM ( EXEC google_analytics_src.getV4( viewId => 68903984, startDate => '2017-04-01', endDate => '2017-04-02', metrics => 'users,newUsers,percentNewSessions', dimensions => 'date', samplingLevel => 'LARGE', sort => 'users' )) a

```
