Skip to content

Instantly share code, notes, and snippets.

zjuul / add-missing-datalayer-event.js
Created Sep 14, 2020 — forked from sahava/add-missing-datalayer-event.js
This piece of code adds a default 'event' key-value to each dataLayer.push() that hasn't got one.
View add-missing-datalayer-event.js
(function() {
var oldPush = window.dataLayer.push;
window.dataLayer.push = function() {
var states = [], 0);
states.forEach(function(s) {
if (!s.hasOwnProperty('event')) {
s.event = 'default';
return oldPush.apply(window.dataLayer, states);
zjuul / wide_to_long.sql
Last active Apr 20, 2020
Transform your long data to wide data - to break down the request in phases
View wide_to_long.sql
create or replace table `PROJECTNAME.DATASETNAME.performance_long` partition by DATE(timestamp) as
with base as (
timestamp, date, event_timestamp, clientid, user_id, device_category, country, url, hostname,
page_path, page_title, page_referrer, type
from `PROJECTNAME.DATASETNAME.performance_wide`
,intervals as (
zjuul / transform_to_wide.sql
Created Apr 14, 2020
Transform Performance Navigation data to wide format
View transform_to_wide.sql
create or replace table `PROJECTNAME.DATASETNAME.performance_wide` partition by DATE(timestamp) as
wide version of nested events table
TIMESTAMP_MICROS(event_timestamp) as timestamp,
DATE(TIMESTAMP_MICROS(event_timestamp)) as date,
zjuul / tdf.R
Created Jul 9, 2019
Tour de France 2019 - plot general classification
View tdf.R
# url with TDF standings
url <- ""
standings <- fromJSON(content(GET(url), "text")[[1]])
View GTM_track_autocomplete.js
// GTM custom HTML tag for tracking incomplete searches
// logic: if user starts typing, start a timer. Stop the timer when user is idle 2.5 seconds
// then push the event on the DL
(function() {
var timer, firstResult, searchText;
var waiting = false;
var waitTime = 2500; // milliseconds
zjuul / all_join_types.sql
Created Aug 23, 2018
SQL joins: all in one
View all_join_types.sql
-- create two tables: L and R
-- content of tables a "val" column with two rows.
-- rows in L: "left only" and "both"
-- rows in R: "right only" and "both"
with l as (
select 'both' as val
select 'left_only' as val
), r as (
View cohort_chart.R
# From:
########## 1: get data
appname <- "NAME" # used as selection criterium, replace that with the name of your app
q <- paste0("
TO_CHAR(CONVERT_TIMEZONE('UTC', 'Europe/Amsterdam', derived_tstamp),'YYYY ww') AS yw
WHERE app_id = '", appname, "' AND derived_tstamp >= '2018-01-01'
zjuul / supershort_manual.txt
Last active Aug 7, 2018
G-dash on synology nas
View supershort_manual.txt
Step 1: Download the binaries
(choose Gulden- )
Step 2: unpack the binaries on your NAS somewhere, create a data directory
(outside home, outside web root)
Step 3: create Gulden.conf file inside the data directory
zjuul / weatherdata.R
Created Jun 18, 2018
KNMI NL weerdata graphing
View weatherdata.R
# visualise weather in NL
# (c) Jules Stuifbergen 2018 - Creative Commons licence CC BY-SA