Overview

This guide explains how to set up Google Analytics 4 (GA4) server-side tracking using Hardal. Server-side tracking improves data accuracy, enhances privacy compliance, and helps bypass ad blockers by moving data collection from the browser to a server environment.

Server-side tracking doesn’t replace your existing GA4 implementation entirely. It changes where and how the data is processed before being sent to Google Analytics.

Prerequisites

Before you begin, ensure you have:

This guide assumes you have already implemented the Hardal tracking script on your website. If you haven’t done this yet, please refer to the Hardal Website Installation guide first.

Why Use Server-Side Tracking for GA4?

Server-side tracking offers several advantages over traditional client-side implementation:

FeatureClient-SideServer-Side
Ad-blocker resilienceVulnerable to blockingHighly resilient
Data accuracyCan be affected by browser issuesMore accurate
Privacy complianceExposes user data in browserBetter data control
Site performanceImpacts page load timesMinimal client impact
Data controlLimited processing optionsAdvanced processing

Implementation Steps

1

Configure GA4 Client in Server Container

In your server-side GTM container:

  1. Go to “Clients” and click the built-in “GA4” client
  1. Configure with the following settings

    • Priority: 0 (default)

    • Default GA4 paths: Enabled

    • Default gtag.js paths: Enabled with your GA4 Measurement ID(s)

    • Automatically serve dependent scripts: Enabled

    • Compress HTTP response: Enabled

    • Enable region-specific settings: Disabled

    • Cookies and Client Identification: JavaScript Managed

  1. Save your client configuration
2

Create GA4 Server Tag

  1. In your server container, go to “Tags” and click “New”
  1. Select “Google Analytics: GA4” as the tag type
  1. Configure with the following settings
  1. Create a custom trigger that fires on “Some Events” where “Client Name equals GA4”
  1. Name and save your tag (e.g., “GA4 Server Tag”)
3

Configure Web Container Tag

In your client-side GTM container:

  1. Create a new “Google Tag” tag
  1. Enter your GA4 measurement ID

  2. Add a configuration parameter:

    • Name: server_container_url

    • Value: Your Hardal sGTM Tagging URL (from the Server-Side Hosts page)

  1. Add appropriate triggers (e.g., All Pages)

  2. Save and publish your container

For optimal performance and first-party data collection, set up a custom domain for your Hardal endpoint before implementation.

Validation and Testing

After setting up server-side tracking, validate your implementation:

1

Test in Preview Mode

  1. Enable Preview mode in your web container

  2. Enable Preview mode in your server container

  3. Navigate to your website

  4. Verify events are being received by the server container

  5. Confirm the GA4 tag is firing in the server container

2

Check Real-Time Reports

  1. Open GA4 Real-Time reports

  2. Perform actions on your website (page views, events)

  3. Verify the events appear in the real-time report

If using parallel measurement (both client and server), you’ll need to check both GA4 properties.

3

Validate Event Parameters

Ensure critical parameters are being passed correctly:

  1. Check that user_id and client_id are being preserved

  2. Verify custom parameters are included in events

  3. Confirm engagement metrics (engagement_time_msec, session_id) are present

Troubleshooting