Guide
Switch from Google Analytics 4 and Tag Manager to lytics
lytics does the counting of GA4 and the triggers of Tag Manager in one script, with no cookies. It also does much less than GA4. This guide shows how to run the two side by side, what each GA4 and Tag Manager feature becomes, and what you lose by moving, so you can decide before you remove anything.
1. Install lytics next to what you have
Keep your Google tag or Tag Manager container for now. Create an account, add an app with the domains your site is served from, and paste its snippet into the <head> of every page, beside the one it will replace. The two do not interact.
Add: the lytics snippet
<script>window.lytics=window.lytics||function(){(lytics.q=lytics.q||[]).push(arguments)};</script>
<script defer src="https://lytics.lp-data.cloud/api/t/lyt_REPLACE_WITH_YOUR_SITE_KEY.js"></script>Remove later: the Google tag
<!-- 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>Or remove later: the Tag Manager container
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXXX');</script>
<!-- End Google Tag Manager -->lyt_REPLACE_WITH_YOUR_SITE_KEY with your app's key, or copy the whole snippet from the app's Install section. The placeholder cannot collect anything.On Astro or Next.js, the placement is slightly different: see the Astro guide or the Next.js guide.
2. Run both for a couple of weeks and compare
Two weeks covers every day of the week twice, and leaves time to spot an event you forgot. If you want a clean year of data from 1 January, install lytics by mid-December so the comparison is done when the year starts.
The two will not match, because they count differently. There is no target percentage to hit: look for the same shape from day to day, and investigate if one tool is missing a page or a whole day.
| Number | Why the two differ |
|---|---|
| Pageviews | The closest pair, so compare these first. lytics sends a pageview when the path changes, so a URL that changes only in its query string is not a new pageview there. |
| Days | lytics days are UTC. Google Analytics uses the time zone set on its property, so single days can disagree at the edges. Compare whole weeks. |
| Visitors and Users | lytics counts visitors per UTC day, and over a range adds the days up. A GA4 user is recognised across days by a cookie, so a weekly lytics figure will usually be higher. Compare single days. |
| Visits and Sessions | A lytics visit is the first event from a visitor in thirty minutes, and one that runs across midnight UTC counts as two. A change of IP address during the day also starts a new visitor. |
| Consent | If a banner holds Google Analytics back until a visitor accepts and lytics is not held back the same way, the two are counting different groups of people. |
| Bots and blockers | lytics drops crawlers and headless browsers by their user agent, and content blockers may stop either tool. Each tool’s filters and blocklists differ, so some gap is normal. |
The metric definitions say exactly how each lytics number is counted.
3. Move each feature across
| GA4 or Tag Manager | lytics | What to know |
|---|---|---|
gtag('event', name, params) | lytics('event', name, props) | Names are letters, digits, spaces and _ . : - $, up to 64 characters; any other name is dropped without an error. Up to 20 properties, with keys of up to 40 characters and values that are strings (cut at 200 characters), numbers or booleans. Nested values such as GA4’s items array are skipped. |
GA4 user_id | lytics('identify', id) and lytics('login', id) | Call identify on every page while someone is signed in: the id is held in the page’s memory. Call login once, right after a successful sign-in, so it counts as their last login. Ids are up to 128 characters. Send your own opaque id, not an email address. |
| GTM trigger: Click | Click tag, made in the dashboard | A CSS selector and an event name, with an optional path prefix. A click on the element or anything inside it counts. No deploy: it reaches every page within five minutes. |
| GTM trigger: Form Submission | Submit tag, made in the dashboard | The selector has to match the <form>, not its button. A form sent by a script calling form.submit() fires no submit event, so no tag can see it. |
| GTM trigger: Page View | Page tag, made in the dashboard | A path prefix and an event name. The prefix is compared as plain text from the start of the path; there is no “contains” or regular expression. |
GTM variables and dataLayer.push events | lytics('event', name, props) from your app | A tag sends its event name and nothing else. It cannot read the data layer, or attach properties. |
| GTM tag: Custom HTML | No equivalent, by design | lytics cannot put code on your pages. A tag is a selector or a path and an event name. Anything that runs as a Custom HTML tag today has to move into your app or stay somewhere else. |
| GA4 enhanced measurement: page changes based on browser history | Automatic | A pageview is sent on history.pushState, replaceState and back or forward navigation. For routers that do not use the history API, call lytics('page'). |
| GA4 enhanced measurement: outbound clicks, file downloads | Click tag with a selector you write | Not collected automatically. For example, a[href$=".pdf"] matches links to PDF files. |
| GA4 enhanced measurement: scrolls, video engagement | lytics('event', name, props) from your app | Not collected automatically, and there is no tag type for them. Your own code has to notice these and send the event. |
| GA4 reports embedded through Looker Studio | lytics embeds (/api/embed/…) and Postgres panels | An embed shows the app’s numbers and the database panels pinned to it, over 7, 30 or 90 days, and only on the sites you list. Panels chart query results from your own Postgres as a number, a table, columns or a line. Postgres is the only kind of database lytics connects to, and the layout of an embed is fixed. |
The tags reference and Track button clicks and form submissions cover tags in detail. Embed a web analytics dashboard and Build a Postgres signup dashboard cover the replacement for embedded reports.
What does not carry over
Read this before you commit. If you rely on any of these, lytics is not a full replacement today, and you may want to keep GA4 for that part or choose another tool.
- No query strings, so no UTM campaign parameters. Only the path of each page is kept, so
?utm_source=…never reaches lytics, and neither do site-search terms in a URL. If you need to count a campaign, give it its own path, such as/go/spring: paths are kept, and a Page tag can name the event. - The referrer is a hostname only. You see
news.example.com, not which article linked to you. A referrer from the same site is not recorded. There are no channel groupings. - Visitors are counted per UTC day. The same person on two days is two visitors, and lytics cannot recognise a returning visitor. Only Users, the ids your app sends, carry across days.
- No country or location data. The IP address goes into the visitor hash and is not stored or looked up. For devices you get mobile, tablet or desktop, with no browser, operating system or screen size.
- No revenue or e-commerce reports. You can send a
purchaseevent and it will be counted, but there are no revenue, product or checkout reports, and anitemsarray is not stored. - Event properties are stored, not charted. The dashboard and embeds count each event by name. There is no breakdown by property, so
format: 'csv'is kept with the event but no report shows it. - No import of historical GA data. lytics stamps each event when it arrives, so old data cannot be loaded. Your lytics history starts the day you install it. Removing the Google tag stops new data and does not delete the property, so leave it in place or export what you need.
- Raw events are kept for 400 days. Plan on about thirteen months of history, not an unlimited archive.
- No funnels, cohorts, audiences or Google Ads links. The dashboard is a fixed set of numbers: visits, visitors, pageviews, users and logins, with top pages, referrers, devices and events.
- No workspaces, versions or preview mode. A tag goes live when you add it, within five minutes. The Live section of the dashboard, which lists each event as it arrives, is where to check it. An app can have up to 50 tags.
Most of the list follows from not storing anything on the visitor's device and not collecting query strings. How lytics counts visitors without cookies gives the reasoning and what it does and does not change about consent.
Worked example: a small GA4 setup, rewritten
A site with a signup link, a contact form, signed-in users and one custom event, tracked with GA4 from hand-written listeners:
// Once the visitor is known
gtag('config', 'G-XXXXXXXXXX', { user_id: 'u_8f2c' });
// A signup click and a contact form submit
document.querySelector('#signup-cta').addEventListener('click', function () {
gtag('event', 'signup_click');
});
document.querySelector('#contact-form').addEventListener('submit', function () {
gtag('event', 'contact_submit');
});
// In the export handler
gtag('event', 'report_exported', { format: 'csv', rows: 1200 });In lytics the two listeners go away and become tags, and the other two calls stay in your code:
// On every page, while someone is signed in
lytics('identify', 'u_8f2c')
// In the export handler
lytics('event', 'report_exported', { format: 'csv', rows: 1200 })Right after a successful sign-in, call lytics('login', 'u_8f2c') as well, so it counts as that user's last login. Then add the two tags under Tags on the app's page:
| When | Matching | On paths starting | Send the event |
|---|---|---|---|
| An element is clicked | #signup-cta | empty — every page | signup_click |
| A form is submitted | #contact-form | empty — every page | contact_submit |
The event names are the ones GA4 was using, which makes the two tools easier to compare while both run. Once migrated, the sample sends:
| The visitor | Event sent |
|---|---|
| Opens a page while signed in | pageview |
| Clicks the signup link | signup_click |
| Submits the contact form | contact_submit |
| Exports a report | report_exported |
Have more than a handful of events? The event tracking plan builder checks names and properties against these limits and writes the calls for you.
4. Remove Google Analytics
When the numbers make sense and nothing in the list above is holding you back:
- Check the Tag Manager container first. It may also be loading ads, chat or other tags that have nothing to do with analytics. Those need a new home before the container goes.
- Remove the snippet from every page, including Tag Manager's
<noscript>block after<body>, and anygtagordataLayer.pushcalls left in your code. - Update your privacy notice and any consent banner if they name Google Analytics.