Google Tag Manager Server-Side — Parsing Event Data From Any Custom Vendor Request

Google Tag Manager Server-Side Custom Event Parser Overview

How The Template Works

1) The configuration requires a path to tell the client, which requests it should handle. You can also specify a cookie from your request, which will be stored in the event data (more on that below). This is optional.

GTM server-side custom event parser configuration
GTM server-side custom event parser data mapping
const getAllEventData = require('getAllEventData');
const event = getAllEventData();
GTM server-side custom event parser variable

Why This Is Important

The event data object is the central connection between client and tag in a GTM server-side environment. It is the client’s output and the tag’s input. Having all available information in a consistent object structure is an important part of a centrally managed data model in a server-side tag manager.

Closing Thoughts

The custom approach is the most interesting. Along with a universally applicable data collecting method, this would be the first step towards implementing a vendor-agnostic and unified data model in a first party context. Thus, reducing dependence on non-transparent vendor-specific client-side scripts, which end up cluttering many websites.


September 2021: While the original client template was designed to only handle GET requests, I have updated the Github repository as well as the documentation and this article to also handle POST requests. This update mainly includes also parsing the request body into the event object.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store