Client-Side Tagging
Third-Party Mode
Third-Party Mode (TPM) is the traditional method of collecting data in GA4, where tracking scripts (e.g., gtag.js or Google Tag Manager) run directly in the user’s browser. When a user interacts with a website—such as viewing a page, clicking a button, or completing a purchase—the browser executes JavaScript to collect data and send it directly to GA4 servers (e.g., google-analytics.com).
Since the domain name google-analytics.com that sends data is a third-party domain name, it is called Third-party mode
- Requirements:No
- Advantages:
- Ease of Implementation: Third-party mode is straightforward to set up using GTM or gtag.js, requiring minimal server-side expertise.
- Rich Browser Data: It automatically captures browser-based data (e.g., referrer, screen resolution) for detailed reporting.
- Widespread Use: Most websites use Third-party mode , making it well-documented and supported
- Disadvantages:
- Ad Blockers and Privacy Restrictions: Ad blockers and browser features like Safari’s Intelligent Tracking Prevention (ITP) can block tracking scripts or limit cookie lifespans (e.g., 7 days for third-party cookies).
- Performance Impact: Multiple tracking scripts can slow down page load times, affecting user experience.
- Data Privacy Risks: Third-party scripts may collect unintended personally identifiable information (PII), raising compliance concerns.
First-Party Mode/Google Tag Gateway
First-Party Mode (FPM) now renamed Google Tag Gateway. It loads the GTM tracking code from your own domain name and forwards it to the GA4 server disguised as a first-party request. (This method is called CNAME deployment in Adobe Analytics).
- Requirements:The website needs to use a CDN, such as CloudFlare
- Advantages:
- Privacy Compliance: First-party cookies are less likely to be blocked by browsers like Safari and Firefox, improving tracking reliability.
- Longer Cookie Lifespan: First-party cookies set by the server avoid ITP’s 7-day expiration, allowing longer-term user tracking.
- Enhanced Trust: Data collection appears to originate from your domain, aligning with user expectations for privacy.
- Disadvantages
- DNS Configuration: Setting up CNAME and Route traffic
Server-SideTagging
Server Side Tagging (SST) , SST is to install GTM tags on your own server. The GTM code is loaded from your own server. The data will be sent to your own server first, and then forwarded to the third-party analysis platform.
- Requirements:You need to use your own server.
- Advantages:
- Ad Blocker Resilience: Server-side tracking bypasses ad blockers and browser restrictions, capturing data that client-side tracking might miss.
- Improved Data Control: You can filter, validate, or remove PII before sending data to GA4, enhancing privacy compliance.
- Better Performance: Reduces browser-side JavaScript, improving page load speed.
- Extended Cookie Lifespan: First-party cookies set by the server can have longer lifespans (e.g., 1 year) compared to browser-set cookies
- Disadvantages:
- Complex Setup: Requires technical expertise to configure a server-side GTM container or Measurement Protocol API, plus server hosting costs.
- Limited Browser Data: Some data (e.g., geolocation, referrer) requires client-side support, necessitating a hybrid setup.
- Cost: Hosting a server (e.g., on Google Cloud) incurs ongoing expenses, which vary based on traffic.
There are some paid SAAS solutions that can greatly simplify Server Side Tagging, such as Stape、TAGGRS、JENTIS.