top of page

Server to Server with sGTM

When you first heard the term "server side tagging", did your mind conjure up a vision of no tags in the browser and the web server squirting data straight into Google Analytics?


Yes? The more typical server side data collection architecture is actually closer to a proxy server. The browser sends data to your server first, before your tags on your server send data to Goole, Meta, Pinterest, Tik Tok, and so on.


However, you certainly can use Server Side Google Tag Manager (sGTM) for server to server communication. There's a lot to be said in favour of breaking data silos by integrating analytics data with other data sets at the point of collection.


No data set value is maximised if it remains in isolation. You can integrate your data sets by a method of message exchange between servers. And a great way to tackle inter-server communication is with Pub/Sub. This is highly performant and scalable. Let's explore.

Summary

I've written previously about integrating sGTM with Pub/Sub - there's a no-code solution, and a Cloud Function based solution. This article covers a demonstration of the breadth of use cases for Hermes (messenger God of Greek mythology) - a tag template that supports sending data from sGTM to Pub/Sub.


Setup

In short - very simple. Head to the Hermes repo and follow the instructions. Tackling the prerequisites is probably the hardest part - some Google Cloud experience/expertise required.


Use cases

Having followed the instructions, your tag template is setup ready to go.


What next?

What's it for?


Promotion - sGTM -> CDP

A user makes a transaction on your site - they use a particular promotion code. sGTM will post a message on the Pub/Sub promotions topic when the item_promotion field is not empty.


  • Update the merchandising team on promotion usage

  • Power a promotion performance dashboard

  • Power MMM with promotion performance data

  • Promotion profitability measurement

  • Brand impact data

  • CLV data collection


Low Stock - sGTM -> eCommerce

You're measuring transactions using sGTM and GA4 - your ecommerce system feeds a lookup table in sGTM to record low stock thresholds for certain high value SKUs. You record a transaction for the BOWL-10 product. Your tag sequence performs a check to see if a low stock threshold approaches. Yes, you're about to go low on BOWL-10 so you need immediate action.

Slightly Off Topic

When testing the Pub/Sub connector, I didn't want to pollute any GA4 properties with spurious test data but I did want to use the GA4 client to claim the request and trigger the tag. I didn't want to write my own client this time. So, I used the bare minimum URL below to triggre the tag:

https://YOUR_SGTM_ENDPOINT.com/g/collect?v=2&tid=G-0000&en=LowStock&ep.sku=BOWL-10 Don't worry, I've deleted the Pub/Sub topic so don't try spamming me!

Server to server

In the context of transaction measurement, the concept of having your ecommerce back end talking directly to your analytics data collection endpoint is attractive. You don't have to expose any ecommerce data on the client, and you don't have to rely on the browser, and ad blocker playing nicely. Assuming you have consent to measure the user behaviour, the server-to-server conversation has a lot of arguments in favour - robustness being a big plus. But it can be a technical challenge. It's well documented already so I won't regurgitate the whole solution here but you must make sure your hits sent to sGTM are correctly decorated with a valid client ID, session ID and a timestamp less than 72 hours from the end of the session in question.


Reverse - Pub/Sub triggered Cloud Function -> sGTM

This post describes are workflow to automate the update of a lookup table in sGTM (https://www.linkedin.com/posts/reliably-doug-hall_data-enrichment-using-sgtm-activity-7203768166609514497-eHSC


The completion (success or failure), of the container publication is recorded in Pub/Sub. Consider how automation reporting, retries, and fault tolerance is powered by the message bus.


Indeed, even the Cloud Function used to update sGTM via the Admin API is triggered by a CSV file landing in Cloud Storage. Automation is powered by effective messaging so sGTM and Pub/Sub integrations open up an even wider range of use cases.


Conclusion

That's a small set of ideas to illustrate the versatility of the solution. The limitation being the connection between what is possible, and what's required while avoiding solutionism.


Pub/Sub isn't a hammer for when everything looks like a nail. Consider data pipelines, and breaking data siloes. Potential data set integrations that deliver value are ideal starting points. Start using Hermes, and sGTM, and let me know what use cases you find.

173 views0 comments

Recent Posts

See All

BEST of Marketing Analytics Summit

First of all, Happy New Year from everyone at Duga Digital. We've started 2025 at pace with Doug (Director of Analytics) having the...

Comments


CONTACT US

Lime Tree Work Shop, Lime Tree Walk, Sevenoaks, Kent, TN13 1YH

info@dugadigital.com

  • Facebook
  • LinkedIn

Registered in England and Wales no. 13177452.
VAT Registration no. 397 6168 39.

bottom of page