This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: PageInfos2GTM | |
Plugin URI: https://www.gandke.de/ | |
Description: Nach Aktivierung werden Angaben zu Loginstatus Autor, Monat, Jahr, Kategorie und Tags als wp_utype, wp_aut, wp_month, wp_year, wp_cat und wp_tags - zusammen mit einem Event "wpPageInfo" - als Script im Footer von Seiten oder Beiträgen in den dataLayer geschrieben, um diese z. B. via Google Tag Manager in benutzerdefinierten Dimensionen zu nutzen. | |
Zudem wird der Seitentitel uebersetzungssicher als org_page_title im dataLayer konserviert. | |
Achtung: Das verwendete Template muss wp_footer() aufrufen (was aber die meisten tun sollten ;)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/******************************************************************************************************/ | |
//send hits to GA- or GTM tag-server: use this file via transport_url | |
//more info: https://developers.google.com/tag-manager/serverside/send-data | |
/******************************************************************************************************/ | |
//define destination for tracking hits - either on www.google-analytics.com | |
//or own tag server like https://trk.myserver.com/collect or | |
//https://gtm-xxxxxx-xxxx.xx.x.appspot.com/collect : | |
$endpoint = "https://www.google-analytics.com/collect"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function() { | |
//Hauptelement eines Blog-Contents selektieren | |
var txt = document.querySelector('#cmain').innerText; | |
var lng = txt.split(" ").length; | |
var l = lng / 300; | |
//300 Worte / Minute Lesezeit oder mindestens 30 Sekunden zurückgeben | |
lng = (lng == 0) ? 30 : l * 60; | |
return Math.round(lng * 1000); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#--------------------------------------------------------------------------------- | |
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
//use this script to adjust size of Matomo Tag Manager preview / debug console | |
//usage: create html tag in MTM, paste this code and fire tag on DOM ready, if "Preview Mode" is "1" | |
var mtmPreviewSize; | |
//resize MTM preview via console | |
function resizeMtmPreview(prz) { | |
//only in preview mode | |
if ({{PreviewMode}}) { | |
var mtm = document.querySelector('iframe#mtmDebugFrame'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// add one of the two following options to the functions.php of your child theme in order to send server side | |
// conversion data to Google Analytics | |
// NOTE: function store_gclid() is used by both variants | |
/***************************************************************************************************/ | |
// send conversion to Analytics - Option 1: track success page as only pageview in the session and | |
// create a goal for path "/conversion/" | |
// adjust goal path (fragment) in $goalurl in order to fit your url structure | |
// comment out line below to deactivate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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). | |