Where to Install Google Analytics?
Figuring out where to install new software can feel like a puzzle, but placing your Google Analytics tracking code is surprisingly straightforward. The key principle is simple: the code needs to be on every single page of your website you want to track. We'll show you exactly how to do that, whether you're using a popular platform like WordPress or Shopify, a tool like Google Tag Manager, or have a custom-built site.
What Exactly Is the Google Analytics Tracking Code?
Before you install it, it helps to know what "it" is. The Google Analytics tracking code is a small snippet of JavaScript that you add to your website. Whenever someone visits a page on your site, their browser runs this script. The script then collects anonymous information about the visit - like how they got there, what page they’re on, and what device they’re using - and sends it all back to your Google Analytics account.
Think of it as a diligent greeter at the door of every room in your business. It logs every entry and notes whether the visitor came from down the hall or from outside, without ever knowing their name. If a room (a webpage) doesn't have this greeter (the tracking code), you'll have no idea who visited or what happened there.
You'll typically encounter two pieces of information from Google Analytics 4:
- The Measurement ID: This looks like
G-XXXXXXXXXX. It's a unique identifier for your stream of data. Most modern platforms and website builders will just ask you for this ID. - The Global Site Tag (gtag.js): This is the full JavaScript snippet. It includes your Measurement ID and is the code you'll use if you're installing it manually or via some theme settings.
Note: If you have a brand new website or aren't selling anything just yet, make sure you disclose your use of analytics cookies in your privacy policy, which is a requirement of GDPR and other regulations.
The Recommended Spot: Install with Google Tag Manager
If you're A) looking for the most flexible "best practice" method, or B) think you'll ever want to add other tracking tools (like a Facebook Pixel, a HubSpot tracking code, or a LinkedIn Insight Tag), then using Google Tag Manager (GTM) is the way to go.
Why use Google Tag Manager? GTM acts as a central "container" for all your marketing and analytics scripts. Instead of cluttering your website's code with five different tracking snippets, you install only the GTM code. Then, you manage all your other tags from inside the GTM interface. It keeps your site code clean, speeds things up, and lets you add or remove tracking tools without ever having to edit your website's files again.
How to Install Google Analytics with GTM
The process involves two main stages: putting GTM on your site, and putting Google Analytics inside GTM.
- Create a Google Tag Manager Account: If you don't have one, go to tagmanager.google.com to create a free account and a new "container" for your website.
- Install the GTM Snippet on Your Site: GTM will give you two small pieces of code. The first goes as high as possible in the
<head>section of your website's code, and the second goes right after the opening<body>tag. Don’t panic - most website builders have a dedicated field for your GTM ID (likeGTM-XXXXXXX) that handles this for you automatically. - Create a New Tag in GTM: Inside your GTM container, click "New Tag."
- Configure the Tag: Name it something clear, like "GA4 Configuration." For the "Tag Configuration," choose the built-in "Google Analytics: GA4 Configuration" tag type. In the "Measurement ID" field, paste your GA4 ID (the
G-XXXXXXXXXXone). - Set the Trigger: Next, for "Triggering," choose the "Initialization - All Pages" trigger. This tells GTM to fire your Google Analytics tag on every single page as it loads.
- Save, Preview, and Publish: Save your tag. It's always best to use the "Preview" mode to test that your new tag is firing correctly on your live site. Once you're confident it's working, click the "Submit" button to publish your changes.
With this setup, Google Analytics is now installed, and you have a clean foundation for any future tracking needs.
The Easiest Route: Use Your Website Builder's Built-In Integration
For most users, this is the quickest and easiest way to get started. Almost every major Content Management System (CMS), website builder, and e-commerce platform has a simple, built-in feature for adding Google Analytics. It avoids any code-editing and is designed to be beginner-friendly.
The general workflow is almost always the same: Find your GA4 Measurement ID (G-XXXXXXXXXX) from your Google Analytics account, then find the specific settings area in your website builder's admin dashboard and paste it in.
On a WordPress Website
With WordPress, you have a few excellent options that don't require you to touch a line of code:
- Google Site Kit Plugin: This is Google's official plugin for WordPress users. When you install it, it securely connects your site to Google Analytics (plus Search Console and other Google services) using a guided setup process. This is the recommended route for a direct-to-GA integration without using Tag Manager.
- Other Analytics Plugins: Plugins like MonsterInsights or Rank Math often include a dedicated field where you can paste your GA4 Measurement ID. They can also provide simplified analytics dashboards right inside your WordPress admin area.
- Theme Settings: Some more advanced WordPress themes include built-in settings to add tracking codes. You'll usually find this under "Theme Options," "Customizer," or "General Settings." Just look for a field labeled "Header Scripts" or "Google Analytics ID."
On a Shopify Store
Shopify makes this incredibly simple. Their integration is built right into the platform because seeing conversion data is critical for e-commerce.
- From your Shopify admin, go to Online Store > Preferences.
- Scroll down to the "Google Analytics" section.
- Paste your GA4 Measurement ID (
G-XXXXXXXXXX) into the box. - Click "Save."
That's it. Shopify automatically handles adding the code to every page, including your checkout pages, and sets up enhanced ecommerce tracking so you can see product views, add-to-carts, and purchases in GA4.
On a Wix or Squarespace Site
Both Wix and Squarespace follow a similar, user-friendly approach targeting non-developers.
- Wix: From your main dashboard, go to Marketing & SEO > Marketing Integrations. Under "Google Analytics," click "Connect," and then follow the simple on-screen instructions to paste in your Measurement ID.
- Squarespace: From the Home menu, click Settings > Third-Party Tools. Click "Google Analytics," and then paste your Measurement ID into the "Measurement ID" field. Click "Save."
Platforms like these handle the precise placement of the code for you, so all you have to do is provide your unique ID.
The Direct Method: Manually Adding the Code to Your Site Files
This method is generally intended for custom-built websites that aren’t built on a major platform like the ones above. It involves directly editing your website's source code, so it comes with a friendly warning: always back up your files before editing them! A tiny typo could potentially break your site layout.
To do this, you'll need the full Global Site Tag (gtag.js) snippet from your GA4 interface. It looks like this:
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [],
function gtag(){dataLayer.push(arguments),}
gtag('js', new Date()),
gtag('config', 'G-XXXXXXXXXX'),
</script>The universal rule for manual installation is to place this entire code snippet immediately after the opening <head> tag on every page of your website. Putting it high up in the <head> ensures that it loads as quickly as possible, allowing it to capture data even from visitors who leave your site before the page fully loads.
Fortunately, most modern websites are built with "template" or "include" files. This means you don't actually have to edit every single HTML file. You'll likely just need to find one central file - often named something like header.php, header.html, or base.html - that contains your site's <head> section. Paste the code there once, and it will be included automatically across your entire website.
How to Check If Google Analytics Is Working
After you've placed the code, you need to verify it's working. Don't just assume it is! Here are three easy ways to check.
- GA4 Realtime Report: This is the simplest check. In your Google Analytics account, go to Reports > Realtime. Now, open your website in a new browser tab or on your phone. In a minute or so, you should see yourself appear as "1 user" on the Realtime map and in one of the cards below. If you're a new user or came from a search you also might appear in the First user source or First user campaign reports too. If you see visitor activity, it's working!
- View Page Source: On your website, right-click anywhere on the page and select "View Page Source." This will open a new tab with your site's raw HTML. Use your browser's find function (Ctrl+F or Cmd+F) and search for your Measurement ID (e.g., "G-12345ABCDE"). If the code snippet is present, the installation was successful.
- Google's Tag Assistant Extension: Install the "Tag Assistant Legacy (by Google)" extension for the Chrome browser. When you visit your site, click the extension icon. It will show you all the Google tags it found on the page. You should see your Google Analytics tag, and it should have a green check status.
Final Thoughts
Whether you're pasting a simple Measurement ID into your Shopify settings, using the power of Google Tag Manager, or editing your site's core files, the fundamental goal is the same: get your unique tracking code on every page. For most, platform integrations are the fastest starting point, while Tag Manager offers the best route for long-term flexibility.
Once you connect your analytics, the real work of turning all that data into actionable insights begins. This is where we built Graphed to help. Instead of wrestling with complex report builders, we let you connect data sources like Google Analytics in just a few clicks. Then, you can ask for dashboards and reports in plain English, allowing you to ask questions and get answers in seconds, not hours.
Related Articles
How to Enable Data Analysis in Excel
Enable Excel's hidden data analysis tools with our step-by-step guide. Uncover trends, make forecasts, and turn raw numbers into actionable insights today!
What SEO Tools Work with Google Analytics?
Discover which SEO tools integrate seamlessly with Google Analytics to provide a comprehensive view of your site's performance. Optimize your SEO strategy now!
Looker Studio vs Metabase: Which BI Tool Actually Fits Your Team?
Looker Studio and Metabase both help you turn raw data into dashboards, but they take completely different approaches. This guide breaks down where each tool fits, what they are good at, and which one matches your actual workflow.