Klips: Retrieving Google Analytics 4 data with the REST connector

Use our REST connector to retrieve your data from Google Analytics 4. Follow along with the steps in this article and adjust the example query to bring in your own data.

To use the REST connector to retrieve your Google Analytics 4 data:

  1. Click Data Sources in the left navigation bar.

If you don’t see the above option, go to the bottom of the left navigation sidebar and click your Account Name > Data Sources instead.

  1. Click Create a New Data Source and, on the Where is your data? page, select REST/URL (under Additional options).
  2. On the Configure your data source page, fill in the following information:
  1. At Query URL, enter the following query: https://analyticsdata.googleapis.com/v1beta/properties/<YOURPROFILEID>:runReport

Note: You'll need to insert your own Google Analytics profile id at <YOURPROFILEID>.

  1. At Data format, select JSON.
  2. At Method, select POST.

Note: Google Analytics 4 uses a POST request (unlike Google Analytics v3, which uses a GET request).

  1. At Body, enter the following content:

{

"metrics": [

{

"name":"users" ,

"expression":"totalUsers"

}],

"dimensions": [

{

"name":"date"

}],

"dateRanges": [

{

"startDate":"2022-01-01",

"endDate":"2022-05-09"

}]

}

  1. Expand Query Parameters and add the following parameters:
  • At Name, enter Content-type.
  • At Value, enter application/json.
  • At Type, select Header.
  1. Expand Authentication and select the following:
  • At Type, select OAuth.
  • At Use Existing, select your Google Analytics OAuth token.
  1. Click Get data to retrieve the data you requested in your query.
  2. Optionally, select the checkbox to Model your data. The Google Analytics 4 API returns data in a JSON hierarchical format. If desired, you can model your data to convert it from JSON to a .csv file format.
  3. Click Continue.
  4. Name, choose refresh settings, and, optionally, share your data source.
  5. Click Save.

Have more questions? Submit a request