GA4 Event Tracking Series ④ —— Custom Events(gtag Method) | BCS GA4 Event Tracking Series ④ —— Custom Events(gtag Method) | BCSBCS

GA4 Event Tracking Series ④ —— Custom Events(gtag Method)

Google Analytics BCS 2 years ago (2023-01-31) 2596 Views 0 Comments

Update time: January 13, 2025

This article introduces how to use gtag method to do custom event tracking.

The gtag method is suitable for direct deployment of GA4 without using GTM.

It requires adding gtag tracking code at the tracking location, so it is very inefficient.

If you use GTM, this method does not apply.

Suppose I want to use the gtag method to track events at this location:

GA4 Event Tracking Series ④ —— Custom Events(gtag Method)

 

Step 1 :Add gtag Tracking Code

The usage of gtag is as follows:

gtag('event', '<event_name>', {
  <event_parameters>
});

Set event name as gtag_method, event parameter as label, value as test (you can customize these, as long as you follow the Event Rules)

gtag('event', 'gtag_method', {
      'label':'test'
 });

 

 

The source code is:

<a href="/" >gtag method demo test</a>

After adding the gtag code:

<a href="/" onclick="gtag('event', 'gtag_method', {'label':'test'});">gtag method demo test</a>

Whenever this location is clicked, the gtag_method event will be sent.

 

Step 2 : Preview and Publish

The gtag method requires the plug-in Google Analytics Debugger to debug.

Open the Google Analytics Debugger, then simulate the user to click, and finally open the Debugview of GA4:

GA4 Event Tracking Series ④ —— Custom Events(gtag Method)

You can see that the gtag_method event is triggered. Click on it to see the event parameter label:

GA4 Event Tracking Series ④ —— Custom Events(gtag Method)

The event parameters are also correct and can be published.

Read  More:

 

Step 3 : Custom Definitions

There is also an event parameter label, if you want to use it in GA4, you need to register it in the Custom definitions of GA4.

In GA4,click「Admin」——「Custom definitions」——「Create custom dimension」, then do the following configuration:

GA4 Event Tracking Series ④ —— Custom Events(gtag Method)

 

 

Step 4 : Verify Data in Reports

Generally, after 24 hours, we can see the data in GA4, such as:GA4 Event Tracking Series ④ —— Custom Events(gtag Method)

 

 

Read More: 


If you don't understand, You can leave a comment below.
Like (1)
Post my comment
Cancel comment
Expression Bold Strikethrough Center Italic

Hi, you need to fill in your nickname and email!

  • Nickname (required)
  • Email (required)
  • Website