1. Where is the Google Analytics 4 Code Placed?
The GA4 tracking code is a JavaScript snippet provided by Google Analytics. This code is the unique identifier that Google Analytics assigns to a property (such as a website, blog, or mobile application). Google Analytics uses this ID within the tracking code to identify and collect activity data and traffic information from users visiting your website.
This is an important step if you want to base your decisions on data for direct marketing campaigns. User tracking activities can be carried out in several ways. The collected data is sent to servers via a 1×1 pixel image.
The data that Google Analytics collects to provide comprehensive reports comes from the following sources:
- The user’s HTTP requests
- Browser/system information
- First-party cookies
2. Setting Up Google Analytics
To use Google Analytics for your website, you need to register for a GA account here, and then follow these steps:
2.1 Create a Data Stream
A data stream is the flow of data from the endpoint (web, app, etc.) to GA. When you create a data stream, GA will generate a code snippet for you to add to your application or website to collect data.
If your system is multi-platform, you should create separate data streams for each platform (e.g., one data stream for an Android application, one for an iOS application, and another for a web application).
To create a new data stream, follow these steps:
Go to Admin, and select Setup Assistant.
Select Tag Installation
Select Add Stream and choose the stream type corresponding to your product platform.
Fill in the required information based on the platform to create a data stream.
2.2 Add the Tracking Code to Your Website
After creating a data stream, GA will provide each stream with a unique Measurement ID. This ID helps identify the data stream when sending requests to GA.
After obtaining the Measurement ID, you can integrate GA into your website by adding the following gtag.js script inside the <header>
tag:
After successfully adding the code, you will see some requests sent to google-analytics.com/g/collect to gather data. Initially, GA will take some time to collect new data before generating reports for users.
3. Getting Started with Google Analytics
3.1 Overview
In the Report Snapshot tab, you can view some key summary information about your system. You can filter data by time range, compare data between different time periods, or add additional comparative information based on user attributes, devices, sessions, etc.
3.2 Acquisition
The information in the Acquisition tab helps you identify where your visitors are coming from. This data is crucial for determining the effectiveness of the marketing strategies you use for your system.
Some of the acquisition information in Google Analytics includes:
Medium
This refers to the mediums through which users access your website. Some common mediums include:
- None: Users access your website directly via the address bar or browser bookmarks.
- Referral: Users access your website through links from other sites, such as Facebook, Instagram, etc.
- Organic: Users access your website through free search engines, such as Google Search, Bing, Baidu, etc.
- CPC: Users access your website through paid ads or campaigns from search engines you paid for.
Source
The Source provides more specific information about where users come from to access your website. For example, with the medium organic, the source could be Google, Bing, Baidu, etc., while for direct, the medium is none.
Campaign
The Campaign represents the name of the Google Ads campaign or custom campaigns you have created for your website.
You can view detailed information by medium, source, or campaign in the chart below. You will see metrics such as interaction rate, interaction time, etc., of users referred through different mediums. From there, you can evaluate the effectiveness and develop appropriate marketing strategies for your website.
In addition to default information, you can fully customize and add other details to this chart.
3.3 Engagement
The Engagement tab contains information about user activities and interactions through the collection of events triggered while users interact with your website.
By default, GA automatically collects essential events on the website, such as page_view, user_engagement, etc. From these events, we can see metrics like the number of views, interactions, etc., for each section of the website.
Additionally, you can create and trigger custom events using the library provided by GA. If you’re using gtag.js, you can use the function:
For important events, you can mark them as conversion events in Configure > Events.
Events marked as conversions will appear in the Engagement > Conversions tab for easier tracking.
4. Retention
The Retention tab displays information about the number of returning and new users, as well as the retention rate—the percentage of returning users who revisit your website. This information helps you monitor and devise appropriate strategies to attract users to continue returning to your website.
5. Demographics
The Demographics tab provides information about user groups, including geographical location, age, gender, interests, etc. This data is crucial for identifying target customer groups who are interested in and suitable for the services or products you offer.
6. Frequently Asked Questions About Retrieving Google Analytics 4 Code
6.1 How to Install Google Analytics 4 Code on WordPress?
You can install the Google Analytics 4 code on WordPress by following these steps:
- Register with Google Analytics
- Set up your Google Analytics 4 account
- Configure your data stream
- Find the GA4 tracking code and copy it from the “data stream” settings
- Install the WordPress plugin to embed the GA4 tracking code
- Paste the GA4 tracking code into the website header
- Verify that your GA4 tracking code is working
6.2 Where to Find the Google Analytics 4 Tracking Code?
After creating a “Web Stream” in GA, you can find the tracking code in the “Web Stream Details” section.
6.3 Where to Embed the Google Analytics 4 Tracking Code?
After copying the tracking code, you need to embed it into the header of your website. You can use Google’s Tag Manager or a plugin to embed the GA4 code into the header.