Custom Events in Google Analytics 4 (dataLayer.push method) | BCS Custom Events in Google Analytics 4 (dataLayer.push method) | BCSBCS

Custom Events in Google Analytics 4 (dataLayer.push method)

Google Analytics BCS 2 years ago (2023-02-01) 3523 Views 0 Comments

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

Meet dataLayer.push method

The dataLayer.push method uses dataLayer.push to send events, which are then triggered by GTM and sent to GA4.

The usage of dataLayer.push is as follows:

dataLayer.push({
  'event': 'customize',
  'color': 'red',
  'conversionValue': 50
  
});
  • Advantage:Tracking is accurate.
  • Disadvantage:Need development support, send dataLayer.push
  • Limit:Use this when other methods fail.
  • Event Rules

Custom Events in Google Analytics 4 (dataLayer.push method)

Event = Event name + Event parameter

Length of event name is up to 40 characters.

Event parameters per event is up to 25, since there are 5 default event parameters, actually 20 can be set.

Event parameters are divided into Event Scope Custom Dimension and Event Scope Custom Metrics.

Event Scope Custom Dimension is up to 40 characters.

Event Scope Custom Metrics is up to 100 characters.

 

Event tracking example: dataLayer.push method

Suppose I want to use the dataLayer.push method to track events at this location:

Custom Events in Google Analytics 4 (dataLayer.push method)

The usage of dataLayer.push is as follows:

dataLayer.push({
 'event': 'datalayer_push_method',
  'color': 'red',
  'clickValue': 1    });

you can customize these, as long as you follow the Event Rules.

 

add dataLayer.push code

This step needs to be developed to add.

 

Variables

In GTM , click「Variables」——「New」——「Choose a variables type to begin setup…」——「Data Layer Variable」,Name it “dlv-color”, and make the following settings:

Custom Events in Google Analytics 4 (dataLayer.push method)

 

Set dlv-clickValue in the same way:

Custom Events in Google Analytics 4 (dataLayer.push method)

 

Note: dlv stands for Data Layer Variable.

 

Triggers

In GTM , click「Triggers」——「New」——「Choose a trigger type to begin setup…」——「Custom Event」,Name it “DataLayer Push”, and make the following settings:

Custom Events in Google Analytics 4 (dataLayer.push method)

 

 

Tags

In GTM , click「Tags」——「New」——「Choose a tags type to begin setup…」——「Google Analytics: GA4 Event」,Name it “Event Tracking-DataLayer Push (dataLayer.push method)”, and make the following settings:

Custom Events in Google Analytics 4 (dataLayer.push method)

 

Preview

Next is the Preview test, you can use any of the following methods:

 

Custom Events in Google Analytics 4 (dataLayer.push method)

The event fires as expected and can be published.

 

Custom definitions

The next step is to register event parameters. This event has event scope custom dimensions and event scope custom metrics:

  • color is event scope custom dimensions
  • click-value is event scope custom metrics

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:

Custom Events in Google Analytics 4 (dataLayer.push method)

 

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

Custom Events in Google Analytics 4 (dataLayer.push method)

 

 

 

The event tracking of the dataLayer.push method is complete.


If you don't understand, You can leave a comment below.
Like (3)
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