Can You Use Google Analytics on Any Website?
Thinking about how to track your website’s performance? The good news is that you can add Google Analytics to virtually any website, as long as you can edit its code. This guide will walk you through how it works, the steps for adding it to different platforms, and how to confirm it’s tracking correctly.
How Google Analytics Actually Works
Before you install it, it helps to understand what’s happening behind the scenes. At its core, Google Analytics works by using a small piece of JavaScript code, often called the Google tag or gtag.js. You place this code snippet into your website's files.
Here’s the simple version of what happens next:
- A User Visits Your Site: When someone lands on a page, their browser reads the page’s code and finds the Google Analytics script.
- The Script Runs: The browser executes this JavaScript.
- Data is Collected: The script silently gathers anonymous information about the visitor and their session, such as their geographic location (country/city), the device they're using (mobile/desktop), the page they're viewing, and how they got to your site (e.g., from a Google search or a Facebook ad).
- Information is Sent to Google: This collected data, known as a "hit," is sent over to Google's servers.
- Processing and Reporting: Google processes all these hits from your visitors and organizes them into the user-friendly reports and dashboards you see inside your Google Analytics account.
The only real requirement for this whole process to work is having the ability to add that initial JavaScript snippet to your website’s code. How you do that depends entirely on what kind of website you have.
Adding Google Analytics to Different Websites
The method for installing the Google tag varies from simple copy-pasting to one-click integrations. Below are step-by-step instructions for the most common website platforms and types.
1. Custom-Coded Websites (HTML, CSS, etc.)
If your website was built from scratch without a content management system (CMS) like WordPress, you'll need to add the code manually. This method gives you total control but requires direct access to the website's files.
Step-by-Step Instructions:
- Find Your Google Tag: Log in to your Google Analytics account. If you just created a property, the tag will be presented to you. If not, go to Admin (the gear icon at the bottom left), select the correct property, go to Data Streams, click your web stream, and find the "Google tag" section. Click "View tag instructions."
- Copy the Code Snippet: You will see a block of code that starts with
<!-- Google tag (gtag.js) -->. Copy the entire thing.
<!-- 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>- Paste the Code into Your HTML: Open your website's HTML files. The best place to put this code is immediately after the opening
<head>tag. It needs to be on every single page you want to track. If your site uses a template file for the header (like aheader.htmlorheader.phpinclude), you can paste it there once to have it appear across your entire site. - Save and Upload: Save your updated HTML files and upload them to your web server. That’s it!
2. WordPress Websites
WordPress is the world's most popular CMS, and it offers multiple easy ways to install Google Analytics. Using a plugin is highly recommended for beginners as it avoids the need to directly edit theme files, which can be risky.
Method A: Using a Plugin (Easiest)
There are several great plugins for this, but Google’s own Site Kit is a fantastic, free choice.
- Log in to your WordPress dashboard.
- Go to Plugins > Add New.
- Search for "Site Kit by Google," then install and activate it.
- Follow the on-screen setup wizard. It will ask you to sign in with the Google account that is connected to your Analytics property.
- Site Kit will automatically verify your site ownership and place the necessary tracking code without you having to copy or paste anything.
Method B: Editing Your Theme Files (More Advanced)
If you prefer not to use a plugin, you can add the code directly to your theme. Important Note: It's a best practice to use a child theme for this. Otherwise, your changes will be erased the next time you update your theme.
- Follow steps 1 and 2 from the Custom-Coded Websites section above to copy your Google tag snippet.
- In your WordPress dashboard, go to Appearance > Theme File Editor.
- From the file list on the right, find and click on the theme header file (usually named
header.php). - Paste your copied Google tag code just after the opening
<head>tag. - Click "Update File" to save your changes.
3. Website Builders (Shopify, Squarespace, Wix)
Most modern website builders have made this process incredibly simple. Instead of needing to copy the full code snippet, you often just need your Measurement ID. This is a unique identifier that looks like 'G-XXXXXXXXXX' and is found in the same place as your full tag snippet in your GA account.
Shopify
- From your Shopify admin, go to Online Store > Preferences.
- Scroll down to the "Google Analytics" section.
- Paste your Measurement ID (G-...) in the box.
- Click Save. Shopify will handle the rest.
Squarespace
- In the Squarespace Home Menu, click Settings, then click Advanced.
- Select External API Keys.
- In the "Google Analytics" field, paste your Measurement ID.
- Click Save. That’s it!
Wix
- From your Wix dashboard, go to Marketing & SEO on the left menu.
- Select Marketing Integrations.
- Under "Google Analytics," click "Connect."
- Click "Connect Google Analytics" and paste your Measurement ID when prompted.
Situations Where You Can't Use Google Analytics
While GA is nearly universal, there are a few scenarios where it won't work or isn't appropriate:
- You Don’t Own the Website: This is the most obvious one. You cannot add your analytics tag to a website you don’t have administrator or developer-level access to.
- The Website is Fully Offline: If you're building a website on your local computer or on a private internal network (an intranet) that cannot connect to the public internet, the tracking script has no way to send data back to Google’s servers.
- Specific Platforms with Strict Limitations: A very small number of highly controlled, "walled-garden" platforms might not allow third-party scripts. This is uncommon for public-facing websites but can happen.
- Sites with Strict Content Security Policies (CSP): Some websites, particularly those handling highly sensitive data, implement a CSP that blocks external scripts from loading and running as a security precaution. This policy would need to be modified by an administrator to allow Google's script to function.
How to Verify Google Analytics is Working Correctly
After installing your tracking code, you should always check to make sure it's working. Here are a few easy ways to do that.
1. Check the Realtime Report
This is the most reliable and immediate method:
- Open your Google Analytics dashboard.
- Go to Reports > Realtime.
- Open your website in a new browser window or on your phone (make sure you don't have any ad-blockers running that might block Google Analytics).
- You should see the "Users in last 30 minutes" count go up to at least "1" and a dot appear on the world map near your location. This is real-time proof that Google is receiving data from your site.
2. View Your Website’s Page Source
Right-click anywhere on your website and select "View Page Source" or a similar option from the menu. This opens a new tab with your site's raw HTML. Use your browser's find function (Ctrl+F or Cmd+F) to search for gtag.js or your unique Measurement ID (G-XXXXXXXXXX). If you find your script in the code, you know it has been installed successfully.
3. Use a Browser Extension
Tools like Google's own Tag Assistant extension for Chrome make it easy to spot tracking tags. Once installed, simply navigate to your website and click the extension's icon. It will tell you if a Google Analytics tag was found and if it's firing properly.
Final Thoughts
Across nearly the entire web, from simple blogs to major e-commerce storefronts, installing Google Analytics is a straightforward and possible task. As long as you can modify your website's code - either directly, through a plugin, or a platform-provided interface - you can start gathering valuable data on your audience and how they engage with your content.
Of course, collecting data is just the first step. The real challenge comes from turning those numbers into actionable insights. At Graphed, we solve this problem. After connecting your Google Analytics account in a few clicks, you can stop wasting hours manually building reports. Instead, just ask questions in plain English - like "create a dashboard showing which traffic sources drive the most conversions" or "what are my top landing pages this month?" - and get complete, real-time dashboards in seconds.
Related Articles
How to Connect Facebook to Google Data Studio: The Complete Guide for 2026
Connecting Facebook Ads to Google Data Studio (now called Looker Studio) has become essential for digital marketers who want to create comprehensive, visually appealing reports that go beyond the basic analytics provided by Facebook's native Ads Manager. If you're struggling with fragmented reporting across multiple platforms or spending too much time manually exporting data, this guide will show you exactly how to streamline your Facebook advertising analytics.
Appsflyer vs Mixpanel: Complete 2026 Comparison Guide
The difference between AppsFlyer and Mixpanel isn't just about features—it's about understanding two fundamentally different approaches to data that can make or break your growth strategy. One tracks how users find you, the other reveals what they do once they arrive. Most companies need insights from both worlds, but knowing where to start can save you months of implementation headaches and thousands in wasted budget.
DashThis vs AgencyAnalytics: The Ultimate Comparison Guide for Marketing Agencies
When it comes to choosing the right marketing reporting platform, agencies often find themselves torn between two industry leaders: DashThis and AgencyAnalytics. Both platforms promise to streamline reporting, save time, and impress clients with stunning visualizations. But which one truly delivers on these promises?