Skip to content

Instantly share code, notes, and snippets.

View mbaersch's full-sized avatar

Markus Baersch mbaersch

View GitHub Profile
@mbaersch
mbaersch / content-visibility-marker.html
Created November 23, 2021 13:13
Custom HTML Tag for Google Tag Manager to create markers in main content for triggering "content consumption" events
<script>
/*
This code can be used as a Custom HTML tag in Google Tag Manager to create invisible "marker lines"
every x percent inside a container (selected via CSS selector) that holds the main content of a page
(like a blog post).
You can then use visibility triggers for the marker lines (selected by name or class) in GTM in order
to fire event tags for Google Analytics or any other tool to measure "content consumption" without
having to rely inaccurate scroll tracking.
@mbaersch
mbaersch / timed-visibility-observer.html
Last active June 9, 2022 10:12
Timed Visibility Observer - HTML-Tag für Piwik PRO Tag Manager zur zeitgesteuerten Auslösung von Visibility Trigger Events
<script>
//******************************************************************************************************
//HTML-Tag für Piwik PRO Tag Manager zur zeitgesteuerten Auslösung von Visibility Trigger Events.
//******************************************************************************************************
//Hinweise siehe https://gist.github.com/mbaersch/8cc6419f3a2b16f6c8641a828460d06e
//Optimierung:
//Die Funktion minimalReadingTime() kann entfernt werden, wenn feste Zeiten oder keine Mindestdauer
//benötigt wird. Ebenso kann dieser Kommentar entfernt werden, um nicht die Ladezeit des Tag Managers
@mbaersch
mbaersch / fix-ecjs-client.tpl
Created October 13, 2021 22:06
fix to fulfil requests for ec.js from a server-side GTM endpoint (Custom Client Template)
___INFO___
{
"type": "CLIENT",
"id": "cvt_temp_public_id",
"version": 1,
"securityGroups": [],
"displayName": "Fix ec.js",
"brand": {
"id": "brand_dummy",
@mbaersch
mbaersch / cached_event_id.js
Last active November 4, 2021 09:41
getUniqueEventId() - creates cacheable event ids for deduplication of events that cannot use the same trigger
/* create unique event ids for specific events that "live" for a limited time
(default: 1 scond).
returns a value that consist of the key, a random number and a timestamp;
dot-separated. An existing value for a key that is requested within the
defined lifespan will remain the same, otherwise (not existing or too old)
a new value is generated and stored. The limited lifespan can be used to
deduplicate several hits of the same type between page loads (e. g. Add2Cart
or multiple PageViews in SPAs).
@mbaersch
mbaersch / enhance_ga4_event_builder.js
Last active September 6, 2022 00:21
Tampermonkey script to add a new section to the GA4 Event Builder for sending payloads to a custom endpoint
// ==UserScript==
// @name Enhance GA4 Event Builder
// @namespace http://tampermonkey.net/
// @version 0.2
// @description add option to send payload to a custom endpoint instead of google-analytics.com
// @author Markus Baersch
// @match https://ga-dev-tools.web.app/ga4/event-builder/
// @grant none
// ==/UserScript==
@mbaersch
mbaersch / tagless-logger-client-demo.tpl
Created April 16, 2021 09:37
Google Tag Manager Custom Client Template to demonstrate processing incoming requests directly without using event data and / or tags
___INFO___
{
"type": "CLIENT",
"id": "cvt_temp_public_id",
"version": 1,
"securityGroups": [],
"displayName": "Tagless Logger Client [DEMO]",
"brand": {
"id": "brand_dummy",
@mbaersch
mbaersch / this-or-that.tpl
Last active August 22, 2021 16:15
This Or That (Server-Side Google Tag Manager Custom Variable Template)
moved to https://github.com/mbaersch/this-or-that
@mbaersch
mbaersch / store_fbc_cookie.js
Created March 22, 2021 12:47
HTML tag code for persiting a fblid as cookie in client-side Google Tag Manager
@mbaersch
mbaersch / 200qapla.tpl
Last active March 20, 2021 11:56
sending debugging hits to your serverside GTM endpoint from the browser manually? make every request a glorious success. I bet you get the joke.
___INFO___
{
"type": "CLIENT",
"id": "cvt_temp_public_id",
"version": 1,
"securityGroups": [],
"displayName": "200 Qapla\u0027",
"brand": {
"id": "brand_dummy",