Don't have one? Create one ↗
← All courses
Lessons in this module

Lesson 17 of 20

Point Your Tag At A Tagging Server

① Connect your GTM container

Paste your container ID to load it into this page. It only ever runs here.

Advanced: use a specific environment

Normally your GA4 tag sends every hit straight to google-analytics.com. The first move in server-side tagging is one setting: server_container_url. Set it, and the same tag sends the same hits to a tagging server you own instead.

You don't need Cloud Run for this lesson: this site hosts a small pretend collector, and you get your own private URL for it below. Point your Google tag at it, fire the tag, and the Server view panel shows your hits arriving, exactly what you'd see landing at a real server container.

One honest caveat: while server_container_url points here, your hits reach this collector instead of Google, and the collector forwards nothing. Perfect for a practice container; just remember to remove the setting afterwards if the tag is one you care about.

Goal

Set server_container_url on your Google tag and watch your own hit arrive at the collector.

Build it in GTM

  1. Copy your personal collector URL

    It's in the card below, https://…/api/sgtm/<your-session>. It's unique to you and remembers hits for about 30 minutes.
  2. Add server_container_url to your Google tag

    In GTM open your Google tag (the GA4 config one), expand Configuration settings, and add a configuration parameter named server_container_url with your collector URL as the value. On an older GA4 Configuration tag, use Fields to Set with the same name.
  3. Make sure the tag fires on this page

    The usual Initialization - All Pages (or All Pages) trigger is perfect: the tag's automatic page_view is all the collector needs.
  4. Preview the live page

    Click Preview in GTM and connect it to this lesson's live URL. When your Google tag fires, your browser sends the hit to your collector, and the Server view below lists it within a couple of seconds.

Debug in Tag Assistant

Copy this lesson's live URL and paste it into GTM Preview, that is the page Tag Assistant connects to. It has the clickable elements, so this page stays clean for reading.

  1. In your GTM, click Preview.
  2. Paste the live URL above and click Connect.
  3. Interact with the live page and watch your tag fire in Tag Assistant.

What you should expect to see

In Tag Assistant your Google tag fires like always. The difference is where the hit goes: in your browser's Network tab the request to /g/collect now targets your /api/sgtm/… URL instead of google-analytics.com, and the same hit appears in the Server view panel.

Verify your container

Built it? Export your container, Admin → Export Container, choose your workspace, then drop the JSON here to check it against this lesson.

Drop your container .json here

or browse · checked in your browser, nothing is uploaded

0 of 20 lessons complete
Was this lesson helpful?