Skip to content

Instantly share code, notes, and snippets.

Avatar

Markus Baersch mbaersch

View GitHub Profile
@mbaersch
mbaersch / full_size_gtm.user.js
Created Sep 22, 2022
Tampermonkey Script for adjusting GTM user interface to full size use
View full_size_gtm.user.js
// ==UserScript==
// @name Full Size GTM
// @namespace http://tampermonkey.net/
// @version 0.1
// @description adjust GTM user interface to full size use
// @author MBSL
// @match https://tagmanager.google.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=google.com
// @grant none
// ==/UserScript==
@mbaersch
mbaersch / kill_ga4_announcement.user.js
Last active Aug 27, 2022
Tampermonkey Script: hide annoying announcement for GA4 in Universal Analytics UI
View kill_ga4_announcement.user.js
// ==UserScript==
// @name Kill GA4 Announcement
// @namespace http://tampermonkey.net/
// @version 0.4
// @description hide annoying announcement for GA4 in Universal Analytics UI (or any other)
// @author MBSL
// @match https://analytics.google.com/analytics/web/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=google.com
// @grant none
// ==/UserScript==
@mbaersch
mbaersch / Universal-Export-R-Beispiel.R
Last active May 2, 2022
Beispielscript zum Export von Daten aus Google Universal Analytics mittels R
View Universal-Export-R-Beispiel.R
#---------------------------------------------------------------------------------
# Beispielscript: Export von Daten aus Google Universal Analytics mittels R
#---------------------------------------------------------------------------------
# Dieses Beispiel gehört zum Blogpost unter
# https://www.markus-baersch.de/blog/universal-analytics-daten-sichern-was-und-wie/
# Damit es nutzbar ist:
# - R installieren: https://cran.rstudio.com/
# - RStudio installieren: https://www.rstudio.com/
# - Dieses Script in RStudio öffnen
@mbaersch
mbaersch / getgtm.php
Last active Mar 18, 2022
Local caching helper for GTM containers
View getgtm.php
<?php
/******************************************************************
Helper for locally cached GTM container: update local GTM cache and
enable optional live container loading for debugging
******************************************************************/
//path and filename for local GTM container cache, relative
//to this PHP file or as absolute server path
$gtm_save_path = "../js/gtm.js";
@mbaersch
mbaersch / content-visibility-marker.html
Created Nov 23, 2021
Custom HTML Tag for Google Tag Manager to create markers in main content for triggering "content consumption" events
View content-visibility-marker.html
<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 Jun 9, 2022
Timed Visibility Observer - HTML-Tag für Piwik PRO Tag Manager zur zeitgesteuerten Auslösung von Visibility Trigger Events
View timed-visibility-observer.html
<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 Oct 13, 2021
fix to fulfil requests for ec.js from a server-side GTM endpoint (Custom Client Template)
View fix-ecjs-client.tpl
___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 Nov 4, 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 Sep 6, 2022
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