Page 1 of 1

How to implement and properly configure Google Analytics 4

Posted: Wed Dec 11, 2024 6:57 am
by mstlucky8072
Adding GA4 with Google Tag Manager
I recommend this method because later you will be able to easily manage tags and add new ones. To add GA4 to the page using Tag Manager, we need to copy the measurement ID, which is located in the tab: Administration > Collect and modify data > Data streams

Data streams
Data streams

After copying the measurement ID, we go to the Google Tag Manager tool. It is important that the container code is on the page where we intend to implement Google Analytics. We add a new tag. In the configuration, we specify the tag type as Google Tag.

Implementing the Google Tag
Implementing the Google Tag

As the measurement ID, we provide the previously copied code. We also need to indicate the rule that will fire the tag on the page. Since Google Analytics — in most cases — should collect data from all pages, we choose the "All pages" rule.

All Pages Rule
All Pages Rule

Then, in preview mode, we can test whether the implemented code works correctly. To do this, in GTM, we need to click the Preview button , and in the next step, provide a link to our website.

Starting preview mode
Starting preview mode

The page will open in preview mode. Now we need to go to Google Analytics 4 and find DebugView mode. You will find it by going to Administration > Data Display > DebugView

DebugView mode displays real-time events and user properties ig database collected by Analytics, allowing you to troubleshoot issues when installing tags or viewing live user activity.

Image


GA4 Preview Mode View
GA4 Preview Mode View

In the screenshot above, we can see that Google Analytics has detected the page_view event, which means it is collecting data. It is now important to publish the changes to the GTM container.

Adding a script to a page template
Another method to implement GA4 on a page is to add a script to the page template - to do this, we need to copy the GA4 script and place it in the source code of the page. Each CMS system will have a different process.

Adding GA4 via plugin
Adding GA4 using built-in integration or a plugin in the site's administration panel. If our site is a store, it is important to implement GA4 using integration, because the most popular Content Management Systems (CMS) have built-in integrations that transfer events related to e-commerce measurement to GA4, such as purchase or add_to_cart .

Basic GA4 configuration
Standard event
One of the basic things we should do is configure the standard events that GA4 measures by default. We can do this in the Administration > Collect and Modify Data > Data Streams section . After selecting the appropriate stream, we enable advanced measurement and go to advanced settings.

Standard Event Configuration
Standard Event Configuration

Then we enable and configure the events we want to measure by default.

Standard events
Standard events

You need to be careful here when triggering the "Website Search" and "Form Interactions" events . To configure the "Website Search" event , you need to verify the name of the parameter in the link containing the search phrase and provide it in the configuration (it is also possible that it will already be added, because several standard GA4 parameters are assigned by default). The "Form Interactions" event measures submitted forms by default - if we have a search engine on the page and it is made as a form, then each search will also be recognized by Google Analytics as a form submission.