Custom Server-Side Google Tag Manager Client Templates

MarkusBaersch1 51 views 33 slides Oct 13, 2024
Slide 1
Slide 1 of 33
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33

About This Presentation

Slides from GTM4ward session 2024-10-15.


Slide Content

Custom GTM Client Templates (and why it is so hard to replace gtag / GA4) Markus Baersch

What is a client in ssGTM?

ssGTM “Receiving Thingies” in ssGTM Events key1: value1 key2: value2 key3: value3 … Tags Tag Tag Tag Clients Client Client Client /endpoint?param1=x&param2=y…

Common client tasks Respond 3 process (response) data from tags send server response (usually) “Decouple” tags from raw requests 2 create event data run container to trigger tags Receive requests 1 different endpoints or same endpoint and different priority (first to “claim” wins)

How “clients” got their name And finally: how should we call those receiving thingies? worker! listener! e ndpoint! collector! sensor! receiver! event processor! client 💩 Senior dev had dark mode and could speak in Courier New. So unfortunately, he took the jackpot… :(

Clients in ssGTM

Clients in ssGTM

Event Data: What tags need to work

Comparing GA4 requests

Q: Will a GA4 request be the same after passing ssGTM? https://www.diffchecker.com/R1z4xmC9/ A: No

Q: What if GA4 adds new parameters?

Everything ends up in X- Files Fields ;)

Building client templates

Building a custom client is easy! https://developers.google.com/tag-platform/tag-manager/server-side/api

Building a custom client is easy!

Forwarding all parameters as event data? E asy!

data.example.com / param_demo ? event_name =my_event& val1 =1& foo =bar& value =42 & currency =EUR& item_id =2& item_name =widget

Custom client use cases Analytics / Data Snowplow Piwik PRO … Proxy Tagless Request Proxy APIs “Cloud Functions” Preflight Requests Alternative (GA4) clients Serve resources Static or dynamic

GA4 requests / client alternatives?

Building a custom GA4 client is (still) easy!

Replacing GA4 requests is not easy GA4 Measurement Protocol Needs help by a web session and drops weights on own foot Universal Analytics Measurement Protocol Goes all the way

Replacing GA4 requests is not easy browser controls everything! e.g. start, count, end of session parameters constantly change ! Consent Mode -> running GA4 on a non-GA4 request stream is hard!

GA4 event data…

… is quite different

Options live with some constraints do not expect data suitable for advertising mimic gtag in the browser and use GA4 client use alternatives like walker OS, Stape data tag do not use GA4 at all ;) -> use custom clients for other tools or tasks!

Example: walker.js in, Piwik PRO out

Example: walker.js in, Piwik PRO out

Server-Side Custom client tips Good to know: always return a response (there is more than a status code) running the container is optional clients can use the same APIs as tags requests can contain multiple events

Server-Side Custom client tips When more clients are used : check your trigger conditions “all events” or “all pages” triggers are no longer your friend use transformations whenever clients and / or tags do not allow event redaction

Done ;)

Thank you! :) markus-baersch.de/slideshare markus-baersch.de/podcast markus-baersch.de/youtube

Build! markus-baersch.de/gtmbook