Implement Piano Analytics With Google Tag Manager Server-Side

Content
Step 1: Sending data via Piano Analytics SDK
Step 2: Receiving data server-side via Custom Event Parser template
Step 3: Sending data via Piano Analytics GTMSS Tag template
Additional tips

Step 1: Sending data

Your standard SDK-based client-side PA implementation can stay in place — full code for an event example below. The only thing that needs to be changed is the collection domain on line 9 of the configuration. This should point to your GTM server-side container. Side note: You can also use the onBeforeBuild or onBeforeSend methods to change the configuration for a single event only. This will allow you to manage multiple collection endpoints on one page, in case you want to test server-side tag management alongside your current implementation and run them in parallel.

Step 2: Receiving the data in GTM server-side

A GTMSS client claims the request and returns a response. It also handles and structures the incoming event data before passing it on to the GTMSS container.

GTM server-side client with Piano Analytics event data
Event object returned to the GTMSS container by the Custom Event Parser client

Step 3: Sending the data from GTM server-side to Piano Analytics

First, configure a custom trigger that fires whenever the Custom Event Parser client has claimed a request. Then, you can use that trigger to run a GTMSS tag, which will use the event data and eventually send it to the PA collection endpoint.

Additional tips

Debugging

The client-to-server-to-vendor configuration adds an extra layer to the data journey, so debugging becomes a tad more important. You can use a combination of browser dev tools, GTM preview modes, and PA data quality tools to monitor and debug the whole data journey:

  1. Browser dev tools or PA Tag Inspector for seeing outgoing requests in the browser
  2. GTMSS preview mode for making sure that client, trigger, and tag are well constructed server-side
  3. PA Stream Inspector to monitor all incoming raw requests across platforms
  4. PA Data Management Rules to modify each parameter of the data stream during pre-processing and map the request content to your data model properties (optional)
  5. See the fully processed event in all reports, interfaces, and APIs within <2 minutes
Piano Analytics Stream Inspector for GTM server-side
Viewing the raw incoming request from GTMSS in Piano Analytics Stream Inspector

Visitor identification and cookie handling

When it comes to visitor identification and cookie handling, you have multiple options:

https://collectDomain.com/event?s=123456&idclient=78c85c7e-d345-41e1-882f-ff4b908113e7
Google Tag Manager Server-side Custom Event Parser Client Configuration
Custom Event Parser: Parsing a custom cookie from the request to the event data 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