Documentation Fundamentals

The login Event in Google Analytics 4 (GA4)

The login event in Google Analytics 4 (GA4) is used to track when a user logs into an existing account.

For many business models, this is an extremely relevant signal: a login typically indicates return visits, trust, and often a specific intent (e.g., checking orders, managing subscriptions, making repeat purchases).
Getting users to log in can be a conversion in itself, because only then can you reliably attribute their interactions to their user account and leverage that data for more accurate, long-term targeting.

The login page from Officine Générale
The login page from Officine Générale

Why this is helpful for marketing & analytics

  • Audiences: “Logged in within the last 30 days,” “Logged in but no purchase,” “Logged in with 3+ sessions.”
  • Funnel analysis: If your checkout requires login, you can clearly represent login as a distinct step in your funnel.

Implementation

The login event should be triggered when the login was successful, not when the user clicks “Sign In.”

dataLayer

javascript
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
    event: "login",
    // optional: how did the user log in? (e.g., email, google, apple, facebook)
    method: "email"
});

Common pitfalls

  • Auto-login / session refresh: Some apps renew tokens in the background or reload login status from the server on every page load and interpret this as a login. That’s not a “login” from the user’s perspective. Only track genuine, intentional logins initiated by the user. Whether a user is logged in or not is also interesting and relevant, but should be captured via the user_id parameter or a custom dimension in GA4 instead.

If you have a complex auth setup (SSO, OAuth redirects, “Remember me”), it’s especially worth defining the logic clearly and communicating it across your team: login should only fire when there’s a truly interactive sign-in—not when an existing login is simply “restored.”