Skip to content

Instantly share code, notes, and snippets.

Avatar

Markus Baersch mbaersch

View GitHub Profile
@mbaersch
mbaersch / cached_event_id.js
Last active Sep 3, 2021
getUniqueEventId() - creates cacheable event ids for deduplication of events that cannot use the same trigger
View cached_event_id.js
/* 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 Aug 12, 2021
Tampermonkey script to add a new section to the GA4 Event Builder for sending payloads to a custom endpoint
View enhance_ga4_event_builder.js
// ==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==
View Consent Mode Configuration (Demo).tpl
@mbaersch
mbaersch / tagless-logger-client-demo.tpl
Created Apr 16, 2021
Google Tag Manager Custom Client Template to demonstrate processing incoming requests directly without using event data and / or tags
View tagless-logger-client-demo.tpl
___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 Aug 22, 2021
This Or That (Server-Side Google Tag Manager Custom Variable Template)
View this-or-that.tpl
moved to https://github.com/mbaersch/this-or-that
@mbaersch
mbaersch / store_fbc_cookie.js
Created Mar 22, 2021
HTML tag code for persiting a fblid as cookie in client-side Google Tag Manager
View store_fbc_cookie.js
@mbaersch
mbaersch / 200qapla.tpl
Last active Mar 20, 2021
sending debugging hits to your serverside GTM endpoint from the browser manually? make every request a glorious success. I bet you get the joke.
View 200qapla.tpl
___INFO___
{
"type": "CLIENT",
"id": "cvt_temp_public_id",
"version": 1,
"securityGroups": [],
"displayName": "200 Qapla\u0027",
"brand": {
"id": "brand_dummy",
@mbaersch
mbaersch / piwikpro-resize-tagcode.html
Last active Mar 26, 2021
PiwikPro Tag Manager Debug Resize
View piwikpro-resize-tagcode.html
<script>
/*
PIWIK PRO TAG MANAGER DEBUGGER RESIZE
adds 200px width to the PiwikPro Tag Manager debug panel and creates links (at top right) to enhance or decrease with in 200 pixel steps
usage: create new (async) html tag in PiwikPro Tag Manager, paste this code and fire tag on DOM ready, if "Preview Mode" is "1".
get preview status from stg_debug cookie as there is no built in variable for debug status (afaik)
*/
function ppResizeDebug(w) {
var pnl = document.querySelector("#seventag_container_debugger");
@mbaersch
mbaersch / konamicode-easteregg.js
Last active Feb 19, 2021
Konami code easter egg for websites
View konamicode-easteregg.js
<script>
/*Animate element and change text / html if konami code is entered on a page - can be used as custom HTML in Google Tag Manager.
Source / idea: https://www.simoahava.com/gtm-tips/add-konami-code-to-your-site/ */
/* SETUP */
//message to display on "konami element" after animation. HTML can be used as well - innerHTML will be replaced with whatever gets defined here.
//leave blank for no change (just animation)
var konamiMessage = 'you are awesome! ;)</small>';
//CSS Selector for element to animate and display message (e.g. "#someId", "div.someclass". info: https://www.w3schools.com/cssref/css_selectors.asp)
@mbaersch
mbaersch / Demo-Client.tpl
Created Sep 8, 2020
Serverside GTM Demo Client + Tag Template
View Demo-Client.tpl
___INFO___
{
"type": "CLIENT",
"id": "cvt_temp_public_id",
"version": 1,
"securityGroups": [],
"displayName": "Demo Logger",
"brand": {
"id": "brand_dummy",