lytics

All guides and tools

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.

Explore a sample dashboardCreate an account
The lytics side was checked against the lytics source as of 2026-11-09. Google's products are described by their public snippets and feature names. This is a migration guide, not a measurement of either tool.

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 -->
Replace 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.

NumberWhy the two differ
PageviewsThe 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.
Dayslytics 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 Userslytics 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 SessionsA 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.
ConsentIf 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 blockerslytics 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 ManagerlyticsWhat 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_idlytics('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: ClickClick tag, made in the dashboardA 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 SubmissionSubmit tag, made in the dashboardThe 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 ViewPage tag, made in the dashboardA 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 eventslytics('event', name, props) from your appA tag sends its event name and nothing else. It cannot read the data layer, or attach properties.
GTM tag: Custom HTMLNo equivalent, by designlytics 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 historyAutomaticA 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 downloadsClick tag with a selector you writeNot collected automatically. For example, a[href$=".pdf"] matches links to PDF files.
GA4 enhanced measurement: scrolls, video engagementlytics('event', name, props) from your appNot 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 Studiolytics embeds (/api/embed/…) and Postgres panelsAn 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.

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:

WhenMatchingOn paths startingSend the event
An element is clicked#signup-ctaempty — every pagesignup_click
A form is submitted#contact-formempty — every pagecontact_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 visitorEvent sent
Opens a page while signed inpageview
Clicks the signup linksignup_click
Submits the contact formcontact_submit
Exports a reportreport_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:

Try it

Explore a sample dashboardCreate an account