As tracking regulations tighten and browser privacy controls grow stronger, client-side analytics are becoming increasingly limited. This is especially true for SaaS platforms that need a reliable, scalable way to monitor user activity across their apps. Enter server-side tracking—a privacy-focused, performance-optimized method that gives you full ownership of your analytics pipeline.
In this post, we’ll explore how to set up custom event tracking using Google Tag Manager (GTM) Server-Side and route that data into Google Analytics 4 (GA4). We’ll walk through tracking a user visiting the login page of your app and prove the full data flow: from the client-side trigger to the server-side container, and finally into GA4.
Why Move to Server-Side Tracking?
Relying solely on client-side tracking leaves you vulnerable to ad blockers, browser restrictions, and third-party data policies. With server-side tagging:
- You reduce data loss caused by client-side blockers
- You gain control over what data is captured and sent
- You improve load times by reducing front-end script overhead
- You ensure better privacy compliance by owning the full data flow
This setup is ideal for SaaS platforms using frameworks like React on the front end and managing custom user journeys across domains and devices.
Step 1: Creating the Trigger on the Login Page
Begin by identifying the event you want to track. In this case, we’re focusing on users landing on the login page (/auth/login) of the app (e.g., app.crmgurus.net).
Within your GTM client-side container:
- Navigate to Triggers and click New
- Set the trigger type to Page View
- Choose Some Page Views and specify the page path as /auth/login
- Name your trigger (e.g., Login Page View) and save it
This ensures the event only fires when users land specifically on the login page, reducing noise in your data.
Step 2: Creating the Client-Side Tag
With the trigger ready, you now need a tag to fire the custom event:
- Create a new GA4 Event tag
- Set the event name (e.g., login_page_view)
- Use your Measurement ID to ensure the event routes to the correct GA4 property
- Link this tag to your new login page trigger
This tag pushes the event to your GTM Server-Side container instead of directly to GA4, allowing for data enrichment, filtering, or transformation before forwarding.
Step 3: Preview and Verify the Event
Enter Preview Mode in GTM and load the login page. You should see the custom event (login_page_view) trigger successfully in the debug panel. This confirms that the client-side GTM container is properly firing the event and routing it to your server-side container.
Step 4: Configure the Event in GTM Server-Side
Now that your server container is receiving the event, you need to create a corresponding server-side tag to forward the data to GA4:
- Open your GTM Server-Side container
- Create a new GA4 tag
- Set the event name (again, login_page_view) and choose Event Name as the trigger condition
- Save and deploy the tag
You’re now capturing the event from your app, routing it through your GTM server container, and sending it securely to GA4.
Step 5: Real-Time Validation in GA4
Open Google Analytics > Realtime, and you should see the custom event (login_page_view) appear in the event stream. This confirms that your data pipeline is functioning end to end: app → client-side GTM → server-side GTM → GA4.
The Value of First-Party Event Ownership
By routing events through your own infrastructure, you’re no longer reliant on GA4 scripts to function perfectly in a client environment. You can:
- Append session data or user identifiers
- Filter or transform events before they reach GA4
- Send the same events to multiple destinations (e.g., GA4, Meta, TikTok, CRM)
This server-side architecture not only enhances data control but also unlocks more reliable insights across your customer journey.
Final Thoughts
What we covered in this setup—tracking a single login page view—is just the starting point. Once your GTM server-side infrastructure is in place, you can scale this model to track:
- Registrations
- Form submissions
- Product views and purchases
- Any meaningful in-app user behavior
In upcoming tutorials, we’ll expand this architecture to include multiple custom events and explore how to enrich or filter data on the server side before sending it to your analytics platforms.
If you're looking for support setting up server-side GTM, GA4, or other analytics services, visit Guru Labs at app.gurulabs.dev for tailored implementation and consultation services.