How to Change Domain on Google Analytics
Moving your website to a new domain name is a big step, and making sure your analytics data follows you correctly is a critical part of the process. This guide provides step-by-step instructions on how to handle a domain change in Google Analytics 4, ensuring you maintain your valuable historical data and accurately track your new site's performance.
First, Understand What "Changing Domains" Means in GA4
Unlike its predecessor, Universal Analytics, Google Analytics 4 isn't rigidly tied to a single domain name within its property settings. A GA4 property is defined by its Measurement ID (which looks like G-XXXXXXXXXX). You can place this same tracking code on multiple domains, and GA4 will collect data from all of them into one property. This is a game-changer for businesses with several related websites.
So, when you 'change your domain,' you're typically dealing with one of these scenarios:
- Scenario 1: Full Site Migration. You've moved your entire website from
old-domain.comtonew-domain.com. Your goal is to continue tracking in your existing GA4 property to keep your history. This will be our main focus. - Scenario 2: Adding a Subdomain or Second Domain. You started with
mybrand.comand now you want to track a blog atblog.mybrand.comor a separate shop atmybrand-shop.comwithin the same property. This involves setting up cross-domain measurement. - Scenario 3: A Totally New Project. The new domain isn't related to the old one at all. In this case, starting with a fresh GA4 property is often the cleanest solution.
This tutorial will walk you through the most common and complex situation: a full site migration.
How to Handle a Full Site Migration to a New Domain
You've rebranded or switched URLs. Congratulations! Now let's make sure your analytics don't miss a beat. The great news is you do not need to create a new property, and you will not lose your historical data. You'll just be telling your existing GA4 property where to listen for new data.
Step 1: Deploy Your Existing GA4 Tracking Code on the New Domain
Before you change any settings in GA, you must get your tracking code working on the new website. Your Measurement ID (G-XXXXXXXXXX) is the same one you used on your old domain. Find it by navigating to:
GA4 Admin > Data Streams > Click your Web stream > View Tag instructions.
How you install this depends on your website setup:
- Using Google Tag Manager (Recommended): GTM makes this process much simpler. You don't need to change anything within Tag Manager itself. Just make sure the GTM container is installed correctly on your new domain.
- Using a CMS Plugin (e.g., WordPress, Shopify): If you use a plugin or app to connect Google Analytics, simply go into that plugin's settings on your new site administration and make sure your existing G-XXXXXXXXXX Measurement ID is entered and saved.
- Hard-coded on Site: If the code was manually placed in your website's
<head>, ensure that the exact GTAG script is copied over and present on every page of your new domain.
Step 2: Update Your Web Stream Settings in GA4
Once the code is on your new property, it's time to update the settings within GA4 to reflect the change. This helps Google Analytics understand where to expect data from and how to process it correctly.
Update the Stream URL
This setting is primarily for GA's internal reference but it's an important housekeeping step.
- Go to the Admin section of GA4 (the gear icon in the bottom-left).
- In the Property column, click on Data Streams.
- Click on the web stream connected to your website.
- In the stream details, click the pencil icon to edit. In the "Stream name" and "Stream URL" field, change the URL to your new domain name (e.g.,
https://www.new-domain.com). It must start withhttp://orhttps://. - Click Update stream.
Configure Your Domains for Cross-Domain Measurement
This is arguably the most important step. To prevent user sessions from breaking as they get redirected from the old domain to the new one, you need to tell GA4 that these two domains are related.
- While in your Webstream details, under Google tag, click on Configure tag settings.
- Under the Settings section, click Configure your domains.
- Here you will see a list of domains. Click Add Condition.
- Enter your old domain name (e.g.,
old-domain.com) and your new domain name (e.g.,new-domain.com). Make sure the match type is set to "Contains". - Click Save.
This configuration helps GA4 maintain session continuity and correctly attribute conversions, even if a user starts on a link pointing to your old domain and gets redirected.
Step 3: Update Your Referral Exclusion List
If you don't do this, traffic coming from your old, redirected domain will show up in your reports as "Referral" traffic from old-domain.com. This messes up your marketing attribution, making it look like your old site is a traffic source instead of attributing traffic to its original source (like Organic Search or a Social campaign).
To fix this:
- Go back to your Webstream details page in the GA4 Admin panel.
- Click on Configure tag settings again.
- Under Settings, click Show more to reveal more options.
- Click on List unwanted referrals.
- Click Add condition.
- Set the Match type to "Referral domain contains" and enter your old domain (
old-domain.com). - It's also a good idea to add payment gateways here like
paypal.comorstripe.comto prevent them from showing up as referral traffic after a purchase. - Click Save.
Step 4: Create an Annotation
An annotation is a small note you can add to your data to mark important events. You’ll thank yourself later for doing this. It provides context for anyone looking at your data in the future, explaining any sudden spikes, drops, or changes in traffic patterns around the migration date.
Unfortunately, GA4 doesn't have a built-in annotations feature quite like Universal Analytics did. The most common workaround is to use the Insights & Recommendations panel:
- From the Google Analytics Home screen, look for the 'Insights' card or icon.
- You can ask a question, such as "How many users did we have on [launch day]?".
- When the result appears, click the thumb-up icon and add your feedback. You can use this feedback text as an informal annotation, noting: "Launched new-domain.com on this date."
Post-Migration Checklist: Don't Forget These!
Fixing GA4 is only part of the process. For a seamless transition, you need to address your wider digital footprint.
- Implement 301 Redirects: This is non-negotiable for SEO. You must set up server-side 301 (permanent) redirects from every page on your old domain to the corresponding page on your new domain. This tells search engines where the content has moved, preserving your search rankings and ensuring users still find you.
- Update Google Search Console (GSC): You need to add your new domain as a new property in Google Search Console. Once verified, submit your new sitemap. Also, use the Change of Address tool in your old GSC property to officially tell Google you’ve moved.
- Reconnect GSC and GA4: In the GA4 Admin panel, under Product links, make sure to link your GA4 property to your new Search Console property. This populates the "Search queries" and other organic search reports in GA4.
- Check Your Ad Campaigns: If you run Google Ads, Facebook Ads, or any other paid campaigns, you must manually update all ad destination URLs to point to your new domain. Forgetting this means you are paying to send traffic to broken links.
- Review Custom Reports and Filters: If you have any advanced reports, segments, or filters in GA4 that use "Hostname" as a dimension, make sure to update them to include your new domain name.
What if I'm Just Adding a Subdomain?
If you're tracking something like blog.mydomain.com in addition to www.mydomain.com, the process is much simpler. GA4 handles this beautifully by default as long as you:
- Place the same GA4 tracking code (G-XXXXXXXXXX) on both the main domain and the subdomain.
- Follow Step 2 (part 2) above and add both
mydomain.comandblog.mydomain.comto your list of configured domains under Tag Settings.
That's it. GA4 will track users as they move between the two properties as a single continuous session.
Final Thoughts
Updating Google Analytics for a new domain might seem intimidating, but it's essentially a logical process of updating your tracking setup and key settings. By moving your tracking code, configuring your data stream, and updating your referral list, you ensure complete data continuity with all your valuable historical information intact.
After a big migration, streamlining your reporting is the perfect next step. A major administrative change like this is an opportunity to improve how you access and understand your data. At Graphed, we help you simplify this entire process by connecting directly to sources like Google Analytics, Shopify, and your ad platforms. Instead of building manual reports, you can just ask questions in plain English to create live dashboards and get instant insights, allowing you to focus on your new site's growth, not on fighting with spreadsheets.
Related Articles
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.
How to Create a Photo Album in Meta Business Suite
How to create a photo album in Meta Business Suite — step-by-step guide to organizing Facebook and Instagram photos into albums for your business page.