TL;DR
- Google's help page says to paste the Google tag right after the opening head tag on every page, or use Google Tag Manager or a CMS field; GA4 Measurement IDs start with G-.
- Google states GA4 may take up to 30 minutes to start collecting data; the Realtime report shows it arriving and DebugView sits under Admin, Data display.
- Site Kit by Google turns on Place Google Analytics code only when no Analytics snippet is detected, and warns during setup if it finds another one.
- Shopify sets GA4 up through the Google & YouTube sales channel and cannot track events while the store is password protected; Wix needs a Premium site and connected domain.
- GA4 standard properties can keep event-level data for 2 months or 14 months; Google says the setting only affects explorations and funnel reports, so set it to 14 months early.
To install Google Analytics, meaning GA4, on a website there are three main steps: create a property in Google Analytics, create a web data stream to get a Measurement ID that starts with G-, then put the Google tag on the site using one method, either pasting the gtag.js code yourself, using Google Tag Manager, or using a CMS connection such as those in WordPress, Shopify and Wix. Once installed, check the result in the Realtime report and DebugView before relying on the data.
This article walks through each step, from creating the account to the settings to change right after installing. The steps and menu names were checked against the help pages of Google Analytics, Google Tag Manager, Site Kit by Google, Shopify and Wix on 26 November 2026. Some button labels may change when Google updates its interface, but the structure of the steps stays the same.
How Many Ways Are There to Install GA4 on a Website
Every method gives the same result: a Google tag that sends data to your Measurement ID running on every page of the site. The difference is who maintains the code and how much flexibility you will want later.
| Install method | Who it suits | What to know |
|---|---|---|
| Paste the Google tag (gtag.js) into the site code directly | Custom-coded sites with a developer looking after them | Must go right after the <head> tag on every page. Adding events later means editing code |
| Google Tag Manager (GTM) | Sites that will add several ad tags and events later | Install the GTM code once, then manage every tag through the GTM web interface |
| A CMS connection such as Site Kit, Google & YouTube on Shopify, or Wix Marketing Integrations | Site owners who do not want to touch code | Easiest to use, but watch for duplicate tags if someone already pasted the code |
The rule that applies to every method is to choose only one method for each Measurement ID. If gtag.js is already in the theme and a plugin or GTM also sends data to the same ID, the data will be duplicated. Details are in the duplicate tag section below.
How to Create the Property and Data Stream
Before installing anything on the site, the data needs a destination, which is a GA4 property. The steps from Google's help page are as follows.
1. Create an account
Go to analytics.google.com with the business Google account. If it is your first time you will see a Start measuring button. If you already have an account, go to Admin, click Create and choose Account. Name the account after the company, choose the data sharing settings and click Next. Use the company's Google account, not an employee's or contractor's personal email, because if that person leaves, access to the data may leave with them.
2. Create a property
Name the property, then choose the reporting time zone and currency. For a business in Thailand, pick the Thailand time zone and Thai baht, because the time zone decides where each day ends in reports. Choose the wrong one and each day's totals will be off. Then click Next to choose your industry category and business size, click Next again to choose how you plan to use Analytics, which Google uses to set the default reports, then click Create and accept the terms of service.
3. Create a web data stream
In Admin, under Data collection and modification, click Data streams, then Add stream, and choose Web. Enter the website URL and a stream name, such as the domain name. This page has the enhanced measurement option, which Google describes as automatically collecting page views and some other events, such as scrolls, outbound clicks and site search. Leave it on; you can switch off individual events you do not want later. Click Create stream to finish.
4. Find the Measurement ID
Open the data stream you just created. Under Stream details you will see the Measurement ID that starts with G- followed by letters and numbers. This is the code every install method needs. If you click View tag instructions under Google tag, the system shows the full code and install options by platform.
A site should have one web data stream. If the business runs several domains that are part of the same customer journey, such as the main site and a checkout on another domain, use the same stream and set up cross-domain measurement rather than creating separate properties.
Method 1: Paste the Google Tag (gtag.js) Into the Site Code
Google's help page says to paste the Google tag code immediately after the <head> tag on every page of the site. The code loads the gtag.js file and runs a config command with your Measurement ID.
- On a site that uses a shared template, such as a common header, paste the code into the header file once and every page gets it.
- On a site built from separate HTML pages, you have to paste it into every file. Miss a page and that page has no data at all.
- On a single-page application that changes pages without reloading, check that GA4 picks up page changes. The page changes based on browser history events option in enhanced measurement helps here.
The upside of this method is that no extra tool is needed. The downside is that every time you want to measure a new event, such as a call button click or a form submission, a developer has to edit the code. Sites expecting to add more ad tags and events therefore usually choose GTM instead.
Method 2: Install Through Google Tag Manager
If the site already has the GTM code installed, you do not need to edit the site code again. The steps from the Tag Manager help page are as follows.
- Open the workspace in GTM, go to Tags and click New. Name the tag, for example GA4 Google tag.
- In Tag Configuration, choose Google Analytics, then Google Analytics. Google's Tag Manager help now lists this as the recommended setup; choosing the Google Tag type still works and is listed as the alternate method.
- Enter the Measurement ID starting with G- in the Tag ID field.
- Under Triggering, choose Initialization - All Initialization Events, so the Google tag loads before other tags.
- Click Save.
- Click Preview, enter the site URL and click Connect. The system opens Tag Assistant so you can see which pages the tag fires on.
- Once checked, click Submit, choose Publish and Create Version, add a version name and description, then click Publish.
A common mistake is to finish the tag but never click Publish. The tag then only runs in Preview mode and no data from real users comes in. Another is a site that has gtag.js built into the old theme and then gets a second set of tags in GTM.
Installing the GTM code itself on the site uses the two snippets GTM provides. The first goes in the <head> and the second goes right after the <body> tag. On WordPress both plugins and theme file edits work, and theme edits should be done in a child theme so they are not lost when the theme updates.
Method 3: Install on WordPress, Shopify and Wix
WordPress with Site Kit by Google
Site Kit is Google's own plugin. Install it from the WordPress Plugins page, then sign in with a Google account that has access to Google Analytics. According to the Site Kit documentation, the plugin lets you choose an existing account, property and web data stream, or have Site Kit create new ones for you.
- If no Analytics code is detected on the site, the Place Google Analytics code option is on by default and Site Kit places the code on every page.
- Site Kit notifies you during setup if it finds another Analytics snippet already on the site.
- If the code is placed elsewhere, such as in GTM, turn off Place Google Analytics code so you can connect the property to view reports in WordPress without placing the code twice.
- You can check the status under Tools, then Site Health and the Info tab, in the Analytics snippet placed field.
Besides Site Kit, some SEO plugins and themes have a field for the Measurement ID. They work too, but pick one place. If the site has plugins and old code piled up from several maintainers, tracing and cleaning up the tracking code is work the WordPress customization team can handle.
Shopify with the Google & YouTube sales channel
According to Shopify's help page, the steps are to create a GA4 property and web data stream and note the Tag ID, then install the Google & YouTube sales channel in Shopify admin and follow the Google tag setup steps Google describes for Shopify. Shopify states that connecting Google Merchant Center is not required to use GA4.
- The store must leave password protection mode first. Shopify states that Google Analytics cannot track events until this mode is turned off.
- After setup, Shopify states that certain ecommerce events are tracked automatically, and other events you want can be added later.
- Shopify recommends linking GA4 to your Google Ads account too if the store advertises.
Stores that previously pasted GA code into the theme.liquid file should remove the old code when moving to Google & YouTube, to avoid duplicate tags. Handling this is part of Shopify web design work that sets up tracking from the start.
Wix with Marketing Integrations
According to Wix's help pages, connecting Google Analytics requires a Premium plan site with a connected domain. The steps are to open Marketing Integrations in the site dashboard, click Connect on Google Tag and enter the Measurement ID. Wix says Google Tag unifies Google Analytics, Google Ads and other Google products. Wix's guide also says to turn off page changes based on browser history and site search in the data stream's advanced settings before you copy the Measurement ID. Google Tag Manager is a separate connection in Marketing Integrations, which Wix describes as an advanced feature.
Check the Install Worked With Realtime and DebugView
Do not treat the install as done until you see real data coming in. Google states that data collection may take up to 30 minutes after installing before data starts to appear.
Realtime report
Open your site in another tab, then go to Reports and choose Realtime in GA4. If the install is correct, you will see at least one user (you) and an event such as page_view within a few minutes. Click through to another page on the site and watch for the new event. Realtime is good for checking whether the tag's data arrives, but it does not show the detail of each event.
DebugView
DebugView sits in Admin under Data display. It shows events one by one with their parameters, only from devices that have debug mode on. The ways to turn on debug mode, per Google's help page, are:
- Tag Assistant or GTM Preview mode: Tag Assistant adds a parameter to the URL that turns on debug mode for your device only.
- Add debug_mode in gtag.js: add 'debug_mode':true to the config command to see every event on the page.
- Add debug_mode to the Google tag in GTM: set debug_mode to true in the tag.
Google states that setting debug_mode to false does not turn debug mode off; you have to remove the parameter. If you forget to remove it after testing, events from real users will show up in DebugView too.
Post-install checklist
- Open the homepage, a product or service page, and the thank-you page after a form submission, and check that each page sends page_view.
- Check in DebugView that each page sends page_view only once.
- Open the page source and search for G- to count how many copies of the code there are.
- Test on mobile too, because some themes load code differently on desktop and mobile.
What Happens if the Tag Is Installed Twice
If two Google tags send data to the same Measurement ID, each event may be sent twice. What you see in reports is abnormally high page views per session, inflated event counts, and key events such as form submissions possibly counted twice, which makes ad measurement wrong as well.
Google's developer documentation also warns about a second case: if you send page_view manually in code without turning off automatic page view measurement (setting send_page_view to false), you can also get duplicate page views.
Common sources of duplicate tags:
- gtag.js code in the theme, plus a plugin or Site Kit placing a second copy.
- A tag set up in GTM while the old gtag.js code is still in the page.
- An SEO or ecommerce plugin with a Measurement ID field that someone filled in.
- A Shopify store with both old code in the theme and a Google & YouTube connection.
The fix is to pick a single install point to keep, remove or switch off all the others, and check DebugView again. Data already duplicated in the past cannot be corrected retroactively, so note the date of the fix for when you compare numbers before and after.
What to Set Up After Installing
Installing the tag only opens the data pipe. The following settings make the data usable for decisions.
- Data retention: in Admin, under Data collection and modification, there is a Data retention menu. Standard properties can choose 2 months or 14 months. Google says the setting only affects explorations and funnel reports, not standard reports. Check it on day one: Google says an increase applies to data already collected, but event data older than the current limit has already been deleted.
- Filter internal traffic: define the office IP addresses as internal traffic in the data stream's tag settings, then activate the data filter so staff visits do not mix with customer visits.
- Key events: choose the events that are business goals, such as form submissions, call clicks, LINE adds or purchases, and mark them as key events.
- Link Google Ads: if you advertise, linking GA4 with Google Ads lets you use key events and audiences in campaigns.
- Link Search Console: to see the Google search queries that bring people in alongside their behavior on the site.
- Cross-domain measurement: if customers move across domains, for example to a checkout or booking system on another domain, set it up on the data stream's Google tag page.
- Consent: if the site uses a cookie banner, check that tags behave according to the user's consent, and consult legal counsel on the requirements of Thailand's Personal Data Protection Act.
An illustrative example (hypothetical): a dental clinic in Bangkok installs GA4 through Site Kit, but the old theme already contains gtag.js code, so reports show each user viewing every page about twice. After turning off Place Google Analytics code in Site Kit and confirming in DebugView that only one page_view remains, the numbers return to normal. The clinic then sets the appointment form submission as a key event and raises data retention to 14 months.
Installing Google Analytics for Websites in Thailand
Many Thai business sites offer contact channels other than forms, such as a LINE button or a call button. Enhanced measurement does not mark clicks on these buttons as key events on its own. Without events set up for clicks on these buttons, reports make it look as if the site produces almost no leads, even though customers are reaching out through chat.
Another issue is the time zone and currency chosen when creating the property. If an overseas contractor created it with their own country's defaults, daily reports will cut days out of step with Thai time and purchase values will show in another currency. Both settings can be checked and changed in Property details in Admin.
Sites that used Universal Analytics before and still carry old code starting with UA- should remove it, because Universal Analytics has stopped processing data. Migrating tracking, setting up key events and checking the data is correct from the start is work the Google Analytics 4 service team takes on. For a site about to be built, planning measurement points at the web design stage avoids tearing out code later.
Frequently Asked Questions About Installing Google Analytics
Is installing Google Analytics free?
Yes, standard GA4 can be used at no cost. All you need is a Google account and edit access to the site or CMS to place the Google tag. Google Analytics 360 is the paid version for large enterprises.
How long after installing will I see data?
Google states that data collection may take up to 30 minutes after installing. The Realtime report usually shows your own visit within a few minutes, while other standard reports can take longer to process.
Should I use GTM or paste gtag.js myself?
If the site will add ad tags or several events later, use GTM, because you can add and edit tags without editing the site code. For a small site that only measures visits, pasting the code or using a CMS field is enough. What matters is choosing one method.
How do I know if the site has duplicate tags?
Check in DebugView whether opening one page sends page_view more than once, and open the page source and search for the Measurement ID starting with G-. If you find several copies, or both gtag.js and GTM sending to the same ID, the tag is duplicated.
Can I use the same Measurement ID on several sites?
It works technically, but use it only for sites that form one customer journey, and set up cross-domain measurement as well. Sites that are separate businesses or brands should each have their own property so the data does not mix.
Summary
A correct Google Analytics install starts with creating a property with the right time zone and currency, creating a web data stream, then choosing a single method to place the Google tag. Check the result with Realtime and DebugView to be sure there are no duplicate tags, then set up data retention, internal traffic and key events straight away. If you want a team to set up and check your whole tracking setup, see the GA4 setup and migration service page.







