GA4 via GTM Server Side Tracking

How to Setup GA4 via GTM Server Side Tracking Properly 2023

1. Understanding Server-Side Tracking:

Setting up Google Analytics 4 (GA4) through Google Tag Manager (GTM) using server-side tracking offers enhanced data accuracy, privacy compliance, and flexibility. This method allows you to send data directly from your server to GA4, reducing reliance on client-side JavaScript tracking. Here’s a comprehensive guide on how to set up GA4 via GTM server-side tracking:

Server-side tracking involves sending data directly from your server to GA4 servers, bypassing the need for client-side JavaScript. This enhances data accuracy and helps with privacy compliance, as sensitive data doesn’t leave the server.

Requirements:

Set Up a Server Container in GTM:

Create a new container in GTM dedicated to server-side tracking. This container will hold tags, triggers, and variables specific to server-side tracking.

2. Configuring Server-side Google Tag Manager Container:

Step 1: Go to the server-side container and find the ‘Tags’ section. Once there, click upon ‘New’.

Server Side Tracking - Adding new Tag - Involvz

Step 2: Give tag a clear and descriptive name. After that, click upon ‘Tag configuration’.

Server Side Tracking - Giving Tag a Name & Selecting Tag Type - Involvz

Step 3: On the right side, you’ll see an overlay. This overlay has the list of the tag templates. 

We’ll pick ‘Google Analytics: GA4‘.

Server Side Tracking - Selecting GA4 Tag Type - Involvz

Step 4: Time to add the GA measurement ID. You can locate this in your GA4 account by going to Admin, and then Data Stream.

Server Side Tracking - Setting up GA4 Tag - Involvz

Step 5: Tap on ‘Triggering’. This is where we’ll create the trigger for the tag.

Server Side Tracking - Selecting Trigger For GA4 Tag - Involvz

Step 6: Tap the ‘+’ symbol to make the new trigger. Give your trigger a name that explains what it does.

There are three trigger types available, We’ll be using the “Pageview”

Server Side Tracking - Selecting Trigger Type - Involvz

Step 7: Tap on ‘Trigger Type’. You can set up when the trigger happens by choosing ‘Some Pageviews’. Also You can create a ‘variable’, to describe when the trigger should happen. Or you can use variables that are already available.

Server Side Tracking - Adding Condition to trigger - Involvz

Step 8: For what we’re doing, we want to send data to GA4. So, we’ll choose a condition that says ‘Client name’ is the same as ‘GA4’.

Server Side Tracking - Condition set to GA4 - Involvz

Step 9: Don’t forget to click ‘Save’.

Now, let’s move on. Next, we’ll check and confirm if the server-side container is getting data from the client-side container & how it sends that data to Google Analytics.

3. Previewing and Debugging

When setting up tracking in Google Tag Manager, it’s important to test things out before you go live. Preview and debugging help you ensure that your tags, triggers, and variables are working as expected.

Previewing:

Step 1: In your Google Tag Manager account, click on the “Preview” button. This lets you see how your tags work on your actual website without making them live.

Server Side Tracking - Previewing GTM server - Involvz

Step 2: A new window will appear with the blank summary.

Server Side Tracking - Opening GTM SS Preview window - Involvz

Step 3: Now, when you go to your website, you’ll see a special GTM panel that shows what tags are firing and what data is being sent.

Server Side Tracking - Receiving pageview hit in SS preview mode - Involvz

To check what exactly the tag did, go to the ‘Tags’ section in the preview. Find the tag named ‘GA4 – Server Side Tag’ (that’s what we called it).

Server Side Tracking - Seeing Which data is send by SS Tag - Involvz

In the ‘Variables’ section, you’ll find a list of things being tracked and their values.

Server Side Tracking - Checking Variable Tab in SS preview mode 2

The ‘Event Data’ part shows all the info collected and sent to the tool, like Google Analytics 4. This way, you can keep an eye on what’s being shared and how your tracking is working.

Server Side Tracking - Checking Event Data in SS Preview Mode - Involvz

Debugging:

Step 1: In the GTM preview panel, you’ll be able to see which tags are triggering and what information they’re sending.

Step 2: If things don’t seem right, you can use the debug panel to track down issues.

Step 3: You can also check the browser’s console for any error messages related to your tags.

Once you’re confident everything is working fine, you can publish your changes in GTM and start tracking data accurately.

Real-Time Validation:

When you’re setting up tracking using tools like Google Tag Manager and Google Analytics 4, it’s important to make sure everything is working correctly in real-time. This is called “real-time validation.”

For it, go to your GA4 account tap on “Real-time” The page given below will appear.

Server Side Tracking - Validating user hit in realtime - Involvz

Setting up Google Analytics 4 events

Here’s what you need to know before you start:

  1. You’ve already set up events for GA4 on your website using tags.
  2. Your website’s tags send data to a server-side container, not directly to GA4.

Now, follow these steps to get your GA4 events by using a server-side container.

Step 1: Go to the ‘Tags’ section in the server-side container and tap on ‘New’.

Server Side Tracking - Making GA4 Event Tag in GTM SS container - Involvz

Step 2: Name your tag so it makes sense and tap on ‘Tag Configuration’.

Server Side Tracking - Making new Event Tag in GTM SS container - Involvz

Step 3: Now, choose the type of tag which is ‘Google Analytics: GA4’.

Server Side Tracking - Selecting GA4 Tag Type in GTM SS Container - Involvz

Step 4: Put in your GA4 measurement ID and tap the ‘+’ sign next to the event name. From the options, choose the ‘Event Name’ variable.

Server Side Tracking - Setting up GA4 Tag in GTM SS Container - Involvz

Tag configuration will appear like this.

Server Side Tracking - GA4 event Tag Setup

Step 6: Tap on the ‘Triggering’ button to make a trigger for our Google Analytics 4 events tag.

Server Side Tracking - Making trigger for GA4 Event - Involvz

Step 7:  Hit the ‘+’ sign to create a new trigger. Give the trigger a name that explains what it does.

Server Side Tracking - Giving a name to trigger - Involvz

Step 8: Tap on ‘Some Events’, then pick ‘Event Name’ from the list that drops down.

Server Side Tracking - Setting Condition for trigger 1 - Involvz

Step 9: From the second drop-down, select ‘Matches regex’. In the box where it says ‘Value’, type in “*”.

Server Side Tracking - Setting Condition for trigger 2 - Involvz

Step 10: After setting everything up, save your settings and turn on the preview mode in the server-side tag manager. Now, go to your website and do some actions, like scrolling or submitting a form. In the picture below, you can see that the scroll and form submit events show up in the summary tag. And, right at the same time, the GA4 events tag is triggered too.

Server Side Tracking - Checking Events in GTM SS preview mode - Involvz

Step 11: Click on the GA4 events tag and see what information it’s sending to GA4.

Look, in the picture, the ‘GA4 Events’ tag got triggered, and it sent the ‘Event Name’ as ‘Form Submit’.

Server Side Tracking - Seeing Which data is send by SS Tag to GA4 - Involvz

Step 12: Next, go to your Google Analytics 4 console and click on ‘Realtime’. You’ll find the ‘Form Submit’ event right there.

Server Side Tracking - Validating Event hit in realtime 2 - Involvz

Great job! You have finally set up the Google Analytics 4 events in the server-side container.

Final Words!

Setting up GA4 via GTM server-side tracking is a robust solution for accurate and privacy-conscious data tracking. By following these steps, you can implement a reliable server-side tracking strategy that enhances data accuracy, improves user privacy, and provides more flexibility in your analytics setup.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top