Why and when to use server-side tagging?
Server-side Tag Manager is designed to give you more control over the data collected from your users. It acts as a buffer between the user and the vendors to whom the data is dispatched.
There are three main reasons for why and when to use server-side tagging:
- Improving privacy controls
- Improving website or app performance
- Improving data quality
Unlock better user privacy controls with server-side tagging
You can control the conditions for data privacy and security for the user by controlling the flow of marketing data.
The figure compares the data flow of a traditional client-side setup with a server-side setup.
![Diagram comparing client-side tagging to server-side tagging.](https://google-developers.gonglchuangl.net/static/tag-platform/learn/images/client-server-side-tagging.png?authuser=1)
Client-side tagging: The user's browser or mobile device communicates directly with vendor servers. It's difficult to control what information gets processed. For example, the IP address of the user is always broadcasted in communications to vendor servers.
Server-side tagging: The data flows from the user to your server container. In the server container, you have control over HTTP requests before sending them to your marketing partners. You can validate, parse, anonymize, or even block HTTP requests to ensure privacy by acknowledging cookie consent and anonymizing user data.
Server-side Tag Manager is typically run in a first-party context with the website it collects data from. This prevents vendors from accessing third-party cookies through the server-side tagging environment. This also allows you to tighten content security policies as the browser needs to communicate with fewer third-party domains.
Furthermore, many of the traditionally "sticky" fingerprint vectors such as IP addresses and other HTTP headers can be obfuscated with server-side tagging. The vendor only sees a request from the server, not from the user's browser or device.
Optimizing client-side performance with server-side tagging
One important task for any web application developer or website administrator is to reduce the load on the user's browser and device.
Solid client-side performance is vital for any website that wants to compete for the user's attention. Unfortunately, marketing tags can be a big contributor to performance bottlenecks in the client.
With server-side tagging, the client needs to do less work. Instead of dispatching multiple almost identical requests to different vendors upon a key event, only a single stream of data needs to be sent to the server container. You can then map the request in the server container and distribute it to all the vendors that need the information.
Similarly, the amount of JavaScript libraries that need to be loaded in the client is greatly reduced. You only need to load the library that builds the request. Depending on your implementation, this is the Google Tag or a Tag Manager web container.
Libraries and resources that serve marketing purposes can be loaded through the server-side tagging environment. By using the server as a Content Delivery Network (CDN), you can add custom cache headers, compression mechanisms, and temporary storage to reduce load times even further.
Server-side tagging helps improve data quality
By moving data processing away from the client and into the server, you can leverage mechanisms to improve data quality.
For example, moving to first-party context with the data flowing from the user's browser means that browser cookies can be set with the HttpOnly
flag, making them more durable and more secure.
Because server-side processes happen outside of the user's browser, they can be used to enrich the data with information that should not be exposed to the browser. This includes API secrets, business-sensitive data (such as profit margins), and user data (such as email addresses and other personal data).
The custom templates used in the server-side tagging environment make it easier to normalize the data collected and processed by the server. The user's browser or device no longer needs to run outdated and possibly even dangerous third-party JavaScript just for the sake of data collection.
Summary
In summary, server-side tagging enables you to be in control of sensitive data and improve data quality while improving site performance.
Next, you'll set up a server container.