How do you add GA4 to an Umbraco site
Hi,
A client has a site with the CMS Umbraco – it has a UA integration but does not seem to have an out-of-the-box GA4.
Has anyone any experience with this CMS and adding GA4, any guidance would be appreciated.
The short answer is:
You can integrate GA4 by adding the GA4 tracking script directly to your Umbraco master template or, for a more robust and future-proof solution, by implementing server-side tracking using a combination of Umbraco webhooks, Google Tag Manager (GTM) Server Container, and the Google Analytics Measurement Protocol.
The server-side approach is highly recommended for better data accuracy, improved page speed, and enhanced privacy compliance, which is essential for a modern setup.
The long answer is:
Since Umbraco doesn’t have an out-of-the-box GA4 integration that suits your needs, your best and most scalable solution is to set up server-side tagging.
This involves three key components: Umbraco’s API/webhooks, a GTM Server Container, and the Google Analytics Measurement Protocol, often facilitated by a service like Stape or your own Google Cloud Platform instance.
The traditional client-side method of adding the GA4 script directly to the master template is simple but suffers from ad-blockers and browser restrictions which compromise data quality.
Umbraco’s API and webhooks are an excellent starting point because they allow the CMS to send real-time data about server-side events directly to an external endpoint, which in this case is your GTM Server Container.
For instance, you can configure Umbraco to send a webhook every time a form submission is successful or when content is published, providing clean, reliable first-party data.
This webhook hits your GTM Server Container, which acts as a proxy.
Within the GTM Server Container, you use the Measurement Protocol to translate the incoming Umbraco data payload into a format that GA4 understands.
The Measurement Protocol is a standard set of rules for collecting and sending event data directly to Google Analytics servers via HTTP requests.
This is incredibly powerful because it allows you to record server-side interactions, such as a successful transaction even if the browser session fails, which improves the accuracy of events like purchase
or
.sign_up
Furthermore, you can enrich this data with information that should not be exposed in the browser, such as User IDs
.
Using a service like Stape or your own Google Cloud Platform for the GTM Server Container is both an excellent and cheap solution.
Itβs excellent because it gives you a dedicated, first-party domain for collecting data, which bypasses many ad-blockers and privacy restrictions, leading to much better data collection compared to client-side.
It is cheap because setting up a basic tagging server on a service like Stape often falls into a free tier for smaller traffic volumes, or is very low-cost compared to the enhanced data quality and future flexibility you gain.
This server-side infrastructure ensures that even Umbraco-triggered events, which are crucial for tracking true conversions, are sent securely and accurately to GA4, augmenting your standard client-side tracking to create a complete and resilient data layer.