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
#------------------------------------------------------------------------------------------------------- | |
# Abhängigkeit zwischen Transaktionen / Makrozielen und Mikro-Zielerreichungen untersuchen | |
#------------------------------------------------------------------------------------------------------- | |
#VORBEREITUNG (einmalig): Installation der Pakete, wenn nicht bereits installiert | |
#Im Bedarfsfall hier das Kommentarzeichen "#" vor den beiden folgenden Zeilen entfernen und | |
#diese ebenfallsausführen | |
#install.packages("googleAnalyticsR") | |
#install.packages("h2o") |
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
/* GTM : use the following code inside a customTask, hitCallback oder a cleanup tag | |
GA.JS : modify your existing tracking code with a customTask or hitCallback and execute the following code | |
GTAG.JS : modify your existing tracking code with a manual page_view event | |
including an event_callback (gtag.js) and execute the following code | |
customTask ga.js - see: https://developers.google.com/analytics/devguides/collection/analyticsjs/tasks#adding_to_a_task | |
hitCallback ga.js - see: https://developers.google.com/analytics/devguides/collection/analyticsjs/sending-hits#hitcallback | |
event_callback gtag.js - see: https://developers.google.com/analytics/devguides/collection/gtagjs/sending-data#implement_event_callback_functions | |
*/ |
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
<!-- | |
Replace existing standard gtag.js tracking-code with this | |
snippet in order to store the Client ID in localStorage and use this ID when present | |
converted for direct code implementation from Simo Ahava´s solution for GTM; see | |
https://www.simoahava.com/analytics/use-localstorage-client-id-persistence-google-analytics/ | |
for details | |
Client IDs will survive deletion of cookies by user or ITP 2.1 |
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() { | |
//statt #content für einen Hauptcontainer mit der Id "content" einen CSS Selektor des Hauptinhaltselements | |
//als Id oder (eindeutige) Klasse eintragen. Sonst zur Not einfach 'body' angeben... | |
var txt = document.querySelector('#content').textContent; | |
//Worte zählen | |
var lng = txt.split(" ").length; | |
//Auf je 500 Worte in Klassen bis maximal 5000 aufteilen, alles unter 251 kommt in die Klasse 250 | |
lng = Math.max(250, Math.min(Math.round(lng/500)*500, 5000)); | |
return lng + " Worte"; | |
} |
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> | |
function addEvent(obj, evt, fn) { | |
if (obj.addEventListener) { | |
obj.addEventListener(evt, fn, false); | |
} else if (obj.attachEvent) { | |
obj.attachEvent("on" + evt, fn); | |
} | |
} | |
// Exit intent trigger |
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> | |
(function() { | |
if (window.history) { | |
var s = document.location.search; | |
var h = document.location.hash; | |
var e = {{Event}}; | |
var n = {{New History Fragment}}; | |
var o = {{Old History Fragment}}; | |
if (e === 'gtm.js' && | |
document.referrer.indexOf('www.google.') > -1 && |
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
//Folgenden Code bei einer direkten Implementierung von Universal Analytics | |
//in den Trackingcode einfügen; vor dem Absenden des Pageviews | |
ga('set', 'customTask', function(model) { | |
var r = document.referrer; | |
//Suchmuster für relevante Suchmaschinen mit "versteckten" Suchparametern | |
var srch = /(suche\.t-online\.de)|(qwant\.com)|(metager\.de)|(duckduckgo\.com)|(ecosia\.org)|(android\.googlequicksearchbox\.)|(search\.yahoo\.com)|(zapmeta\.)|(\.sosodesktop\.com)|(search\.mysearch\.com)|(search\.mail\.com)|(thesmartsearch\.net)|(zdsearch\.com)|(search\.easydialsearch\.com)|(safesearch\.hypersonica\.com)|(search\.v9\.com)|(search\.genieo\.com)|(search\.avast\.com)|(searches\.uninstallmaster\.com)|(search\.handycafe\.com)|(searches\.safehomepage\.com)|(search\.snapdo\.com)|(search\.selfbutler\.com)|(infospace\.com)|(search\.avira\.)/i; | |
//Referrer mit Suchmuster vergleichen | |
if (r.search(srch) > 0) { | |
//passenden Parameter bestimmen | |
var prm = (r.search('yahoo') > 0) ? 'p=':'q='; |
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
#--------------------------------------------------------------------------------- | |
# Beispiel zum Datenvergleich: "Tote" URLs finden | |
#--------------------------------------------------------------------------------- | |
#Für den Zugriff auf GA - bei der ersten Autorisierung unten auf die Console achten und | |
#den Anweisungen folgen. Keine Sorge: Das ist nur einmal erforderlich | |
library(googleAnalyticsR) | |
#Für "schönere" Ausgabe der Tabelle | |
library(knitr) |
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 ;)) |