Login & Sign Up
login and sign_up are GA4 recommended events. Implementing them correctly gives you authentication funnel data — how many users register vs. sign in, which authentication methods are most popular, and where in the funnel authenticated users convert differently from anonymous users.
More importantly, login is the event where you should set user_id — GA4’s mechanism for cross-device and cross-session user identification.
login event
Section titled “login event”When to fire
Section titled “When to fire”Fire login after a successful authentication — after the server confirms the credentials are valid and the session is established. Not on form submission, not on button click — after success.
// After successful authentication responsedataLayer.push({ event: 'login', method: 'email', // how the user authenticated user_id: '12345' // hashed or anonymized user identifier});Login with user properties
Section titled “Login with user properties”The login event is your opportunity to push user properties to GA4 — attributes that should persist across the user’s session and inform your audience segmentation.
dataLayer.push({ event: 'login', method: 'google', user_id: 'hashed_user_42813',
// User properties — these persist in GA4 as user-scoped dimensions user_type: 'returning_customer', user_loyalty_tier: 'gold', account_created_year: '2022', has_active_subscription: true});Event schema
Section titled “Event schema”| Parameter | Type | Required | Description |
|---|---|---|---|
| event | string | Required | Must be "login" |
| method | string | Optional | Authentication method. Recommended values: email, google, facebook, apple, sso. |
| user_id | string | Optional | Hashed user identifier. Never use PII. Must be consistent across sessions and devices. |
sign_up event
Section titled “sign_up event”When to fire
Section titled “When to fire”Fire sign_up after a successful account creation — when the new account has been confirmed on the server, not when the user clicks Submit.
// After successful account creationdataLayer.push({ event: 'sign_up', method: 'email', // registration method user_id: 'hashed_user_new_98765'});sign_up with registration context
Section titled “sign_up with registration context”dataLayer.push({ event: 'sign_up', method: 'email', user_id: 'hashed_user_new_98765',
// Optional: registration context referral_source: 'friend_invite', newsletter_opted_in: true, account_type: 'personal'});Event schema
Section titled “Event schema”| Parameter | Type | Required | Description |
|---|---|---|---|
| event | string | Required | Must be "sign_up" |
| method | string | Optional | Registration method. Recommended values: email, google, facebook, apple. |
| user_id | string | Optional | Hashed identifier for the newly created user. |
Setting user_id in GA4
Section titled “Setting user_id in GA4”The user_id parameter on login and sign_up is special in GA4. When you configure a GA4 Event tag in GTM to send a user_id parameter, GA4 uses it to stitch together sessions and events across devices.
For GA4 to actually receive and use the user_id, you need to configure the GA4 Configuration tag (or Google Tag) to read it. Add a user_id parameter to the configuration tag that reads from a Data Layer Variable — not just as an event parameter on the login event.
// GTM Data Layer Variable: DLV - user_id// Path: user_id
// This variable should be read by the GA4 Configuration tag's "user_id" field// as well as included in the login/sign_up event parametersRecommended method values
Section titled “Recommended method values”Use consistent, lowercase values for the method parameter:
// Standard authentication methodsmethod: 'email'method: 'google'method: 'facebook'method: 'apple'method: 'twitter'method: 'microsoft'method: 'sso' // enterprise SSOmethod: 'magic_link' // passwordless linkmethod: 'phone' // SMS/phone verificationGTM configuration
Section titled “GTM configuration”Both events follow the same pattern:
- Create a Custom Event trigger for
loginand another forsign_up. - Create a Data Layer Variable for
methodanduser_id. - Create GA4 Event tags for each event, mapping
methodanduser_idas event parameters. - In your GA4 Configuration tag, also map
user_idto the GA4 user_id field.
Common mistakes
Section titled “Common mistakes”Pushing PII. Never push email addresses, names, or readable user IDs. Use a server-generated hash.
Firing on form submission instead of success. If authentication fails (wrong password), the event should not fire. Fire only after server confirmation.
Not setting user_id on login. If a user signs in and you don’t push their user_id, you lose the cross-session stitching that makes user-level analysis possible in GA4. Login is the moment to set it.
Different user_id formats between devices. The user_id must be the same string across all devices and sessions for the same user. If your web app generates user_42813 but your mobile app generates 42813, they won’t stitch in GA4.