Google Analytics GA4 Building Reports for Custom Events

In this article we will show you how to display Custom Events in GA4 Reports so you can report on data collected via the Measurement Protocol API.  This is how you can report on Live Chat events that you collect once you set up your GA4 Tag settings in the live chat settings.  This also works for any other custom events you collect and can be for server to server events in Google Analytics.

First we'll show you how to set up your Live Chat settings to start collecting live chat events in GA4.

Step 1.  Set up Google Analytics GA4 Integration with Live Chat

Configuring your live chat settings to track Google Analytics Custom events is easy.  From either our Microsoft Teams Live Chat application, just navigate to your Live Chat Settings in the Teams left side bar.  Then select Edit Chat widget and go to the CSS & Javascript Section.  Here you can enter your Google Tag ID and GA4 API Secret.  Once you save your settings, we'll track custom events for you using a server side event push to analytics.

For our Slack and Web Dashboard customers, login to your Social Intents account, select My Apps --> Chat Widget and navigate to your CSS & Javascript Tab.  Enter your Google Tag ID and GA4 API Secret and click save

Step 2.  Create Custom Definitions for Event Data

Once you set up the GA4 Tag in live chat, we will start sending custom events to Google's Measurement API similar to below.

{
    "client_id": "fsabdfd018998659440002.2d51ss-addf-4ff8-5ee5-b1ab05fdcbd",
    "non_personalized_ads": false,
    "events": [
        {
            "name": "live_chat",
            "params": {
                "action": "chat_answered",
		"agent": "James"
            }
        }
    ]
}

Notice for live chat events we have 2 parameters, 1 called "action" and another called "agent".  So for each of these we are going to set up custom definitions and dimensions for these data points so that we can report on them.

To do this, select the Admin icon in Google Analytics then select Data display, then Custom definitions.

Click on the Create custom dimension button on the top right.

Create a Dimension called Live Chat Action, with Scope = Event, and Event parameter = action.  Then click save.

Do the same for the agent parameter.  Once you have set up these 2 definitions, you should see something similar to this:

Step 3.  Create a GA4 Free form report with your custom dimensions

Now that you've created your custom definitions for your event data from the Google Measurement Protocol, create a Free form report by clicking on Explorations in Google Analytics, then Free form.

Under the Dimensions section, add both your Live Chat Action and Live Chat Agent dimensions as dimensions in this section.
Click the + icon next to Dimensions to select your custom dimensions that you created above.

Step 4.  Select your custom fields for your Free form report in Google Analytics

Once selecting the live chat dimensions, add these dimensions to the Rows section in the second column.  Add the Event name and the Live Chat Action Dimension.  

Typically you'll get a blank report if you set this up immediately after creation the custom dimensions.  Give it a few days to capture some events to display.  You should b e able to see a report similar to below once you have live chat events flowing to your Google Analytics account.

Now you have a custom report on live chat events you can access from the GA4 dashboard.

All set!  Now you've create a custom GA4 Free form report that includes the custom event data you are sending to Google Analytics.