WotWP Blog

Keep your Google Analytics and ad code working when your site moves

A white paper house with three small blank tags tied to it on kraft string, one tag with a green check, on a blue background

The short answer

Your analytics and ad code don't move by themselves. They are small pieces of code inside your website's pages, so a new site only has them if someone puts them back. Do it in this order:

  1. Before the move, write down every code your site carries: your Google Analytics ID, any Tag Manager container, your AdSense publisher ID, your ads.txt file and your Search Console verification.
  2. Put the analytics tag on every page of the new site.
  3. Carry over your ad code and your `ads.txt` file.
  4. Keep your Search Console verification working.
  5. After launch, check that data and ads are arriving.

The rest of this post walks through each step.

Before you start

You need a login to your Google Analytics account, and to AdSense and Search Console if you use them. Do the first step while the old site is still live: once it's gone, so are the clues.

On WordPress, these codes are often added by a plugin or by the theme. That's worth knowing, because plugins and themes don't move to a new platform, so neither does code that lives inside them. Our post on what happens to your WordPress plugins after a move covers the wider list.

Step 1: Write down every code your site carries

Open your live site in a browser, view the page source, and search it for these. Copy each one into a note.

What to search for

What it is

Where else to find it

`G-` followed by letters and numbers

Your Google Analytics measurement ID

Google Analytics, in your web data stream's details

`GTM-`

A Google Tag Manager container

Google Tag Manager

`ca-pub-`

Your AdSense publisher ID

Your AdSense account

`google-site-verification`

A Search Console verification tag

Search Console

Then open your site's address followed by /ads.txt in your browser. If a page of plain text loads, save a copy. If you use other ad networks or a Facebook or TikTok pixel, add them to the list too.

If your site uses Google Tag Manager, which "lets you configure and deploy tags from Google products and third parties" (Tag Manager Help), the container may be carrying several of the others. Moving the container brings them with it.

Step 2: Put the analytics tag on every page of the new site

Google's guide to setting up Analytics for a website says to "Paste your Google tag immediately after the <head> on each page of your website." Every page, not just the home page, or the pages without it won't be counted.

Use the same measurement ID as before, so your history stays in one place. Google notes that the ID "starts with "G-" or "AW-"," and that if your new platform has a field for a Google tag ID, you can enter it there instead of pasting code.

Step 3: Carry over your ad code and ads.txt

If you show ads through AdSense, two things have to come across:

  • The AdSense code in the head of your pages, with your own publisher ID.
  • Your `ads.txt` file, at the top level of your domain. Google's ads.txt guide says to "Upload your ads.txt file to the root directory of your site," so it loads at yourdomain.com/ads.txt.

The file is easy to forget, because it isn't a page anyone visits. If it's missing, Google says "you'll have an alert in your AdSense account," and a site with no file can show a "Not found" status. Google asks publishers to fix it "To prevent any impact to your revenue." If your old file lists other ad networks, keep their lines too.

Step 4: Keep your Search Console verification working

Search Console proves to Google that you own the site. Google's guide to moving a site says: "Make sure your Search Console verification will continue to work after the site move."

How you verified decides what to bring:

  • A verification file: "make sure you don't forget to include your current verification file in your new copy of the site."
  • A meta tag, or Google Analytics: "ensure the new CMS copy includes these as well."

If your domain is changing too, Google suggests you "verify both the old and new sites in Search Console."

Step 5: Check after launch

On launch day, check each item on your list:

  1. Analytics: open the Realtime report in Google Analytics and visit your new site. Google says "Data collection may take up to 30 minutes to begin," so give it a little time.
  2. Ads.txt: open /ads.txt on your domain and make sure the same plain text loads.
  3. AdSense: look for any new alert in your account over the next few days.
  4. Search Console: confirm your property still shows as verified.
  5. Other pixels: open each tool and check that visits are arriving.

Compare your analytics week by week for the first month. A sudden drop to near zero often means a missing tag, not missing visitors.

If your new site runs on EmDash

EmDash, Cloudflare's website platform built on Astro, handles these in the site's layout and files. Its Google AdSense guide puts the AdSense code in the shared layout's head and serves ads.txt from the site's public files, so it loads at /ads.txt. It also notes that the Google Verification field under Settings > SEO is for Search Console verification, not for your AdSense ID. Whoever builds the site does this once, and it then applies to every page.

If you want this done for you

If you'd rather not handle a move yourself, moving WordPress sites to EmDash is what we do. Before anything switches, we check every URL, redirect, form and SEO detail against your live site, and your WordPress site stays live until you approve the new one. The conversion starts at $790 for up to 25 pages, as listed on our pricing. To see whether your site is a good fit and what it would cost, check your site for free.

Frequently asked questions

Will I lose my Google Analytics data when my website moves?

No. Your past data stays in your Google Analytics account. What can go missing is new data, if the new site doesn't carry your Google tag. Put the same measurement ID on every page of the new site and your history continues in one place.

Do I need a new Google Analytics account for a new website?

Usually not, if the domain stays the same. Keep the same measurement ID on the new site. Google's site move guide says that if you want separate reports for a new domain, you can consider creating a new profile.

Where does ads.txt go on a new website?

At the root of your domain, so it loads at yourdomain.com/ads.txt. Google's AdSense guide says to "Upload your ads.txt file to the root directory of your site." Copy the old file's lines exactly, including any for other ad networks.

What happens if ads.txt is missing after a move?

AdSense shows an alert in your account, and your site can show a "Not found" status. Google asks publishers to fix it to prevent any impact to their revenue. Restore the file and check that it loads as plain text.

How do I check Google Analytics is working on my new site?

Open the Realtime report in Google Analytics and visit the new site yourself. Google says data collection may take up to 30 minutes to begin. Then visit a few different pages to make sure each one carries the tag.

Will my Search Console verification survive a website move?

Only if the new site keeps it. Google says to include your verification file in the new copy of the site, or to make sure the new site includes the meta tag or Google Analytics code you verified with.