0

GA4 Help from Klipfolio Support Team

If you’ve started using the new Google Analytics 4 Events and you are ready to track the data, here are some examples of how to connect to the data in Klips. 

The new GA4 API uses a POST request with the dimensions and metrics requested in the BODY

Klipfolio Help Center Link with an example:

*Updated with our new Klips connector for GA4

We've branded a connector as GA4 to help with your new GA4 data sources. 

We've updated our article https://support.klipfolio.com/hc/en-us/articles/13268099902231-Klips-Connecting-to-Google-Analytics-4

You know the new format is to put the query into the BODY part of the POST, so 

The best way to build out your query will be to use the GA4 Query Explorer
https://ga-dev-tools.google/ga4/query-explorer
https://ga-dev-tools.google/ga4/dimensions-metrics-explorer

Helpful Google Links

Google's guide to creating the BODY for your Post request https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport 

 General landing page for GA4 API https://developers.google.com/analytics/devguides/reporting/data/v1 

 Comparing Universal Analytics to GA4 https://support.google.com/analytics/answer/11986666 

 More on Universal Analytics & GA4 changes https://support.google.com/analytics/answer/11583528 

 

If you are looking for PowerMetrics examples - please refer to these links

Connecting: https://support.klipfolio.com/hc/en-us/articles/10413252064279-PowerMetrics-Connecting-to-Google-Analytics-4-NEW-

Example- Standard Events: https://support.klipfolio.com/hc/en-us/articles/12213117240087-Example-Tracking-Google-Analytics-4-events-in-PowerMetrics-NEW-

Example- Custom Events: https://support.klipfolio.com/hc/en-us/articles/12070911665175-Example-Tracking-Google-Analytics-4-custom-events-in-PowerMetrics-NEW-

Debugging Dates: https://support.klipfolio.com/hc/en-us/articles/11935631879319-Why-is-my-Google-Analytics-metric-data-off-by-one-day-when-compared-to-my-Google-Analytics-report-data-

 

Blog post: Guide to migrating to GA4 which includes a  how-to with PowerMetrics https://www.klipfolio.com/blog/guide-migrating-to-ga4 

4 comments

  • 0
    Avatar
    Meggan King

    Here is the example from our Klip doc
    The data source query

    POST https://analyticsdata.googleapis.com/v1beta/properties/HIDE:runReport
    Content-type:application/json

    The key section is the BODY where you will request your Dimensions and Metrics

    {
    "metrics": [
    {
    "name":"users" ,
    "expression":"totalUsers"
    }],

    "dimensions": [
    {
    "name":"date"
    }],
    "dateRanges": [
    {
    "startDate":"2023-01-01",
    "endDate":"2023-03-09"
    }]
    }

    Here we are using hardcoded dates, but that could be replaced using our Date query options

    https://support.klipfolio.com/hc/en-us/articles/216181877-Date-parameters-in-data-source-queries 

    "dateRanges": [
    {
    "startDate":'{date.startOfMonth}',
    "endDate":'{date.yesterday}'
    }]

    The data returned will be in JSON format. This can be modelled, or used directly in Klips in the formula bar

    You'll notice the headers are separate from the data

    The data you'll be working with is under the rows

    In your Klip you can easily select the data

    Dimension Values

     

    Metric Values:

  • 0
    Avatar
    Meggan King

    A more interesting example is requesting multiple Metrics and Dimensions in your POST BODY. In this example, I'm using a standard event from GA4. You can also do custom events

    The POST request hasn't changed, but the BODY is now different

    POST https://analyticsdata.googleapis.com/v1beta/properties/HIDE:runReport
    Content-type:application/json
    {
    "metrics": [
    {
    "name":"totalUsers" 
    },
    {
    "name":"EventCount"
    },
    {
    "name":"EventCountPeruser" 
    },
    {
    "name":"ScreenPageViews" 
    }
    ],

    "dimensions": [
    {
    "name":"date"
    },
    {
    "name":"eventname"
    }
    ],
    "dateRanges": [
    {
    "startDate":'{date.startOfMonth}',
    "endDate":'{date.yesterday}'
    }]
    }

     

    The data returned is in JSON format, but how you select it will be slightly different. Now you will modify the JSON XPath to select specific dimension. Here, my Event Names are in the 2nd dimension, so I will modify the XPATH

    In the Metrics, the Event Count per User is the 3rd metric, so I've modified my XPATH to select it

  • 0
    Avatar
    Meggan King
  • 0
    Avatar
    Kalyani Khandelwal

    Hello! 

    I have another tip! 

    If you are adding the date parameters or variables in the curly braces of the POST body, please ensure that only one set of the curly braces {} is present in one line. 

    For example - 

Please sign in to leave a comment.