Tracking | Google Analytics 4 - Recommended Events

Google Analytics (GA) collects data through events which are triggered by user interactions with a website or mobile app. Any and all information collected by GA4 is communicated via event parameters.
 
This articles explains the purpose of recommended events and gives one example an implementation.
 
mceclip1.png
 

The Four Categories of Google Analytics Events

  • Automatically collected events - basic events like page_view which are collected out of the box requiring no custom code
  • Enhanced measurements events - more advanced out of the box events like scroll and file_download which can be improved with custom parameters
  • Recommended events - predefined custom events that are officially recommended by Google depending on your use case(s)
  • Custom events - created when none of the above categories cover your tracking needs
 

Recommended Events - Documentation

The purpose of this article is to address recommended events and how to implement them as part of your tracking solution. Click here for the official list of recommended events.
 
For each recommended event, parameters are suggested. Click the link for each event to see the documentation details. share is used as an example below.
mceclip3.png
 
Since recommended events do not work out of the box, you will have to do some customization to capture the recommended parameters as custom variables. Clicking the share link shown above links you to the recommended parameters below. 
mceclip4.png
 
In the example above, data is captured when a user shares an image from the website via Twitter. Google's recommendation is to include three parameters in the event tag. For each parameter, data must be collected using Google Tag Manager (GTM) custom variables. 
 

Recommended Events - Implementation

Best practice for Google Analytics tracking is to implement data layer support. Therefore, this article will demonstrate an example using that method.

Step 1: Data Layer Push

Building on the Twitter example above, developers should consult Twitter's official documentation which is beyond the scope of this article but relevant to the extend that the following data layer push should be executed after the Twitter API responds indicating a Tweet has been sent. 

window.dataLayer = window.dataLayer || [];
dataLayer.push({
'event': 'share',
'data' : {
  'method' : 'Twitter',
  'content_type' : 'image',
  'item_id' : 'C_12345'
}
});

Programmatically pushing this data to the data layer makes them available for collection through GTM data layer variables. 

The data layer push is the preferred method because is is more accurate and easier to maintain than capturing values from web or mobile content and interactions. 

Step 2: Data Layer Variables

Create data layer variables to capture the values being pushed to the data layer in Step 1. 

As an example, the screenshot below shows a data layer variable configured to capture the value for 'method' in the data layer push ('Twitter' in this example). 

mceclip0.png

In this case, the name of the variable in Google Tag Manager may vary according to you preferences but the Data Layer Variable Name must match exactly what is shown in order to capture the value as structure in the data layer push code snippet. 

Step 3: Tag & Trigger

Set the recommended parameters with the data layer variables created in Step 2.

mceclip1.png

The trigger for this tag is a Custom Event with an Event name that matches the 'event' value pushed to the data layer. 

mceclip2.png

Conclusion

This same process can be applied and customize to meet your tracking needs. When possible, use the recommended events and parameters provided by Google. The result will be an implementation that is easier to maintain in the future. 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.