Stape/Documentation

How to set up Google Analytics 4 (GA4) tracking

Updated Apr 28, 2025

Important! Before you begin, please ensure that you have:

  1. An active Google Analytics 4 (GA4) account. Follow this link to create a new GA4 account if you don’t have one.
  2. Google Tag Manager web and server containers, as well as a configured server container and custom domain in Stape. Please follow these guides if you don’t have any of those:

How to configure GA4 events

There can be two scenarios:

1. If you do not have GA4 configured inside your web GTM container

1. Inside the Web container, create a new tag of the tag type Google Tag. Enter your Google Tag ID (here’s how to find it).

Add an initialization trigger to GA4 tag.

Сreate a new tag of the tag type Google Tag

Also add the parameter server_container_url with Value = your sGTM container's URL. This parameter signals that events must be sent to the URL.

2. To set up the GA4 event tracking, go to the tags section and create a new tag with the tag type Google Analytics: GA4 Event. Add your GA4 ID and the event name; you can use any custom event names, but most standard GA4 reports are based on standard events, so we recommend using standard event names whenever possible.

Сreate a new tag with the tag type Google Analytics: GA4 Event

3. Go to your Google Tag Manager Server container and check whether you already have a GA4 client. If not, click Clients and New.

Сlick Clients and New

4. Choose Google Analytics: GA4 (web) and click Save. Please consider how you name the client, because you will have to use this name later when configuring the Trigger.

Choose Google Analytics: GA4 (web) and click Save

5. Go to Tags and click New.

Go to Tags and click New

6. Choose Google Analytics: GA4.

Choose Google Analytics: GA4

7. Click Triggering.

Click Triggering

8. Create triggers for the tag. Client name should equal the name you gave to your GA4 client at step 4. Example:

Click New Trigger.

Click New Trigger

Choose Custom type →  click Some events →  choose Client Name in built-in variables →  set Contains GA4 (the name of your GA4 client) →  click Save

Create triggers for the tag

2. If you already configured GA4 inside your web GTM container

1. Add your server container URL to Google Tag settings. In the configuration settings, add the configuration parameter server_container_url and add your tagging server URL as a value

Add your server container URL to Google Tag settings

2. Create Google Analytics 4 client in server GTM container. To do so, open the clients’ section → either use an existing GA4 client or create New client → select client type Google Analytics: GA4 (Web) → add client name (e.g. GA4) and click Save

Create Google Analytics 4 client in server GTM container

3. In the server GTM container create a new tag with the tag type Google Analytics: GA4.

4. Click Triggering and configure a trigger with the trigger type Custom that will fire every time when client name contains GA4 (or the name of the GA4 client that you’ve specified earlier) → click Save

Click Triggering and configure a trigger

(Optional) Set up Custom Loader

Custom Loader modifies gtag.js and gtm.js loading paths to bypass ad blockers, potentially increasing data volume by up to 40%. We highly recommend using this power-up. Please see this page to learn more about Custom Loader and how to configure it. 

How to track eCommerce events in GA4

Stape offers prebuilt GTM container templates for various services and platforms (e.g., Shopify, Wix, WooCommerce, etc.) These are out-of-the-box tracking kits equipped with standard ecommerce events and parameters. If you’re using any of the supported services / platforms, these templates are a great way to streamline your eCommerce event tracking. 

See the complete list of our prebuilt container templates.

How to test and debug GA4 server-side tracking in Google Analytics

Open the Web and Server container preview modes and check that you see GA4 requests. Also, use the Debug view in GA4 to see GA4 receives events and everything works as intended. 

Next, publish the update inside the server and web Google Tag Manager containers. The GA4 Measurement Protocol API allows developers to send data directly to GA4 properties through HTTP requests, enhancing data collection and integration with other server-side options.

Test and debug GA4 server-side tracking in Google Analytics
Can’t find what you are looking for?