How to Update Old Google Analytics Code to GA4 (2026 Guide)
Still have old ga.js, urchin.js or analytics.js tracking code on your site? Then you’re not collecting any data. In 2007 we told readers to update Google Analytics code from urchin.js to the new ga.js. Since then Google has replaced its tracking code several times, and Universal Analytics was shut down completely. Here’s how to check what you’re running and switch to Google Analytics 4 (GA4) in 2026.

Quick answer: Old Google Analytics code (urchin.js, ga.js and analytics.js with “UA-” IDs) no longer collects data: standard Universal Analytics properties stopped processing hits on July 1, 2023. To update, create a GA4 property in Google Analytics, add a web data stream, and install the Google tag (gtag.js) with your “G-” Measurement ID in the head of every page. Then remove the old snippet.
Table of Contents
A short history of Google Analytics tracking code
- urchin.js: the original tracking code, based on Urchin software that Google bought before launching Google Analytics.
- ga.js: introduced in December 2007 with better ecommerce tracking. That’s the upgrade this post originally covered.
- analytics.js (Universal Analytics): replaced ga.js and used “UA-” tracking IDs.
- gtag.js and GA4: the current Google tag and Google Analytics 4, which uses “G-” Measurement IDs and an event-based data model.
According to Google’s Universal Analytics sunset notice, standard UA properties stopped processing data on July 1, 2023, and access to UA data in the interface and API was removed starting July 1, 2024. Any page still running old code sends data nowhere.
How to check which Google Analytics code you have
- Open your site, right-click and choose View Page Source.
- Search the source for
urchin.js,ga.js,analytics.js,gtagandUA-orG-. - If you only find “UA-” IDs or the older scripts, you need to install GA4.
- You can also use Google Tag Assistant to see which Google tags fire on a page.
How to update Google Analytics code to GA4
- Sign in to Google Analytics at Google Analytics. New users click Start measuring to create an account.
- Create a GA4 property: go to Admin, click Create, then Property. Enter a name, time zone and currency, answer the business questions and click Create.
- Add a web data stream: in Admin, open Data streams, click Add stream, choose Web, enter your site URL and create the stream. Leave enhanced measurement on to track scrolls, outbound clicks, site search and more automatically.
- Copy your Measurement ID: it starts with “G-” and is shown in the stream details.
- Install the Google tag: in the stream, click View tag instructions, choose Install manually, and paste the gtag.js snippet into the
<head>of every page. Many site builders and plugins only need the Measurement ID. - Remove the old code: delete any urchin.js, ga.js or analytics.js snippets so the page stays clean.
- Verify: open the Realtime report and visit your site. Data can take up to 30 minutes to appear.
Updating Google Analytics in WordPress
The easiest option is Google’s official Site Kit by Google plugin, which connects GA4 and adds the tag for you. Alternatively, paste the Measurement ID into your SEO or theme plugin’s analytics setting, or add the gtag.js snippet to your theme header. Use only one method so pageviews aren’t counted twice.
Our 2007 update, for the record
Back then, switching from urchin.js to ga.js took about a minute: in the old Analytics interface you clicked Edit next to the website profile, then Check Status, chose the New Tracking Code (ga.js) option and pasted it just before the closing body tag. Google’s warning from that time still applies today: never run two different versions of the tracking code on the same page, or your reports will be inaccurate.
Once GA4 is running, learn how to track more pageviews with Google Analytics 4, how to make more money with Google Analytics 4, and what replaced the adjusted bounce rate in GA4.
FAQ
Does ga.js still work?
No. ga.js, urchin.js and analytics.js sent data to Universal Analytics, which stopped processing data on July 1, 2023 for standard properties. You need GA4.
What is the difference between a UA- and a G- ID?
“UA-” tracking IDs belonged to Universal Analytics. “G-” Measurement IDs belong to Google Analytics 4 properties, the current version.
Can I still see my old Universal Analytics data?
No. Google removed access to Universal Analytics data in the interface and API starting July 1, 2024. If you exported reports before then, keep those files.
Where do I paste the GA4 tracking code?
Paste the Google tag (gtag.js) snippet immediately after the opening <head> tag on every page, or use a plugin or Google Tag Manager to add it.
Get our free weekly email: new tech guides and tools, no spam.
New and updated tech guides, a free tool worth bookmarking and one useful pick, once a week. No spam, unsubscribe anytime.
One email a week. Unsubscribe anytime. See our privacy policy.






I am currently using Google Analytics and I have all pages tagged properly including the receipts page (with the GA ecommerce tracking code)however I cannot seem to get my revenue indicators to report. What might I be doing wrong?
When switching from legacy to the newer ga.js, do you get a lull in statistics?
Check out line 435 of the source of this page the “/” and “” are replaced by their numerical ascii characters
You appear to be using WordPress – I cannot get this new code to validate on my wordpress blog – I am also having trouble with mybloglog and blogcatalog – it is a shame as I would like to use the new code. Did you have any difficulties with validation?
the radical blogger
This is an eye opener to most bloggers. Thanks
ga.js tracking code looks a lot better. I never knew that. Thanks for sharing it! :)