Configure GA4 in the server container
After lesson 3 your server container receives GA4 hits on https://sgtm.example.com/g/collect, but nothing forwards them yet. In this lesson you add the server-side GA4 tag that sends the data on to Google Analytics, look at the privacy options the server gives you, and confirm that events arrive in GA4.
Intermediate 10 min read
What you will learn
- Understand how the GA4 client turns incoming requests into event data.
- Add a Google Analytics: GA4 tag that fires on every event the GA4 client claims.
- Know which options help with data minimisation, and when to switch to server-managed cookies.
- Verify the full path from browser to GA4 in server Preview and GA4 Realtime.
02 Add the GA4 tag
- 1 Open your server container, go to Tags and click New.
- 2 Choose Google Analytics: GA4 as the tag type.
- 3 Leave Measurement ID empty to use the ID that arrives with each event, or enter
G-XXXXXXXXXXto send everything to one property. - 4 Under Triggering, create a new trigger of type Custom that fires on Some Events, with the condition Client Name equals
GA4. - 5 Name the tag, for example
GA4 - all events, and save.
This one tag forwards every GA4 event: page views, sign_up, purchase and anything you add later in the web container. You do not need one server tag per event.
03 Optional: control what reaches Google
Because every hit passes through your server first, you can change it before Google sees it. None of this is required to get data flowing, so come back to it once the basics work.
- Redact visitor IP address in the GA4 tag removes the IP address from the event. GA4 then has no IP to derive location from, so geographic reports lose detail.
- Event Parameters in the GA4 tag let you exclude parameters you do not want to send and add or override values, for example to drop a parameter that contains personal data.
- Transformations (in the server container menu) apply rules to event data before tags read it. Exclude parameters removes fields for the tags you pick; Augment event adds or changes fields. One transformation can cover many tags, which keeps data minimisation in one place.
05 Publish and verify
- 1 Click Preview in the server container. Tag Assistant opens on your subdomain.
- 2 In another tab open your site (or its web container Preview) and browse a few pages.
- 3 In the server Preview, click a
collectrequest on the left. The Request tab should show it was claimed by the GA4 client. - 4 Open the event under that request and check the Tags tab: your GA4 tag is listed under Tags Fired.
- 5 Back on the Request tab, the Outgoing HTTP Requests from Server list shows a request to
google-analytics.comwith status200or204. - 6 Click Submit and publish the server container.
Then open GA4 and check Reports, then Realtime. For a detailed view, go to Admin, then Data display and DebugView; sessions opened from GTM Preview are marked as debug traffic and appear there.
- The GA4 client claims the
/g/collectrequests. - The GA4 tag fires with the trigger Client Name equals GA4.
- The outgoing request to Google returns a 2xx status (usually 200 or 204).
- Events show up in GA4 Realtime or DebugView.
- The server container is published, not only previewed.
If something is missing, the debugging lesson walks through each step of this path.
Frequently asked questions
Do I need a separate server tag for each GA4 event?
No. One GA4 tag triggered on Client Name equals GA4 forwards every event the client claims. You create individual events in the web container.
Everything works in Preview, but GA4 shows no data from real visitors. Why?
The server container is probably not published. Preview only affects your own session; real traffic uses the latest published version.
Does redacting the IP address break anything?
Events still arrive, but GA4 cannot derive location from them, so country and city reports lose detail. Decide based on your privacy requirements.
Ready to put it into practice?
Deploy a server GTM container on your own domain in a few minutes. The Free plan needs no card.
Create a free account