How to Add Google Analytics 4 to Website
Generate the official Global Site Tag (gtag.js) for your website. Just enter your Measurement ID, copy the code, and paste it into your HTML head.
🆔 Configuration
Don’t have it? Check the guide below.
Placement Visualizer
Where does this code go?
Paste the code immediately after the opening <head> tag.
1. How to Get Your Measurement ID
Before you can use the generator above, you need your unique Measurement ID from Google. Here is how to find it:
- Go to Google Analytics: Log in to your analytics account at analytics.google.com.
- Admin Settings: Click the Gear icon (Admin) in the bottom left corner.
- Select Property: In the “Property” column, click on Data Streams.
- Choose Stream: Click on the “Web” data stream for your website.
- Copy ID: You will see a “Measurement ID” in the top right corner that starts with
G-. Copy this string.
2. Installing the Code
Once you have generated the code using the tool above, follow these steps to install it on your site:
For HTML Websites
Open your index.html (and every other page you want to track). Paste the generated code immediately after the opening <head> tag. It must be placed before any other scripts or CSS links for the best accuracy.
For WordPress
The easiest way is to use a plugin, but if you want to add it manually without plugins:
- Go to Appearance > Theme File Editor.
- Find the
header.phpfile on the right side. - Paste the code right after the
<head>tag. - Click “Update File”.
For Shopify
- Go to Online Store > Themes.
- Click the three dots (…) and select Edit code.
- Open the
theme.liquidfile. - Paste the code after the
<head>tag. - Save changes.
3. Verifying Installation
After installing, open your website in a new tab. Then, go back to Google Analytics and navigate to Reports > Realtime. If you see “1 user” (yourself) in the last 30 minutes, the tag is working correctly!
https://quickcalculators.in/how-to-create-a-contact-form-in-html-and-css/