How-To

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

  • 10 June 2024
  • 0 replies
  • 11 views

Userlevel 6
Badge
  • Community Manager
  • 22 replies

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

  • get: Uses the Reporting API v3
  • getV4: 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:

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 Google's migration guide for a mapping of old to new values.

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

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

0 replies

Be the first to reply!

Reply