Skip to content

Instantly share code, notes, and snippets.

Simo Ahava sahava

Block or report user

Report or block sahava

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
sahava / customTaskMonster
Last active May 20, 2019
One customTask to rule them all.
View customTaskMonster
var _customTask = function () {
// customTask Builder by Simo Ahava
// More information about customTask:
// Change the default values for the settings below.
// clientIdIndex: The Custom Dimension index to where you want to send the visitor's Client ID.
var clientIdIndex = 1;
sahava / customtask-builder
Last active Feb 26, 2019
customTask Builder
View customtask-builder
<div id="customTaskWrapper">
<th>Click to select which feature(s) to include</th>
<td data-customtask-id='cid' data-customtask-selected='false'>Client ID as a Custom Dimension</td>
sahava / dataLayerHistory.js
Last active May 17, 2019
JavaScript for persisting dataLayer array and data model composition across pages
View dataLayerHistory.js
(function() {
// Set the timeout for when the dataLayer history should be purged. The default is 30 minutes.
// The timeout needs to be in milliseconds.
var timeout = 30*60*1000;
// Change dataLayerName only if you've defined another named for the dataLayer array in your
// GTM container snippet.
var dataLayerName = 'dataLayer';
// Don't change anything below.
View snowplow-application-config
# Copyright (c) 2013-2018 Snowplow Analytics Ltd. All rights reserved.
# This program is licensed to you under the Apache License Version 2.0, and
# you may not use this file except in compliance with the Apache License
# Version 2.0. You may obtain a copy of the Apache License Version 2.0 at
# Unless required by applicable law or agreed to in writing, software
# distributed under the Apache License Version 2.0 is distributed on an "AS
sahava / add-missing-datalayer-event.js
Created Feb 26, 2019
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);
sahava / allowlinker-ga.js
Last active Sep 27, 2019
This script reproduces Google Analytics' allowLinker plugin, resulting in a function that returns true if the linker parameter in the URL is valid and false otherwise. Uses the "old" linker plugin format. You can also pass a string as an argument to check if that string is a valid linker parameter.
View allowlinker-ga.js
var checkLinker = function(str) {
// First browser fingerprint method.
// Uses the clientId / gid string, user agent, time, and browser plugin descriptions.
var joiner = function (cidGid, offset) {
var a = new Date,
b = window.navigator,
c = b.plugins || [];
var d = [cidGid, b.userAgent, a.getTimezoneOffset(), a.getYear(), a.getDate(), a.getHours(), a.getMinutes() + offset];
for (var e = 0; e < c.length; ++e) {
sahava / Facebook Pixel.tpl
Last active May 23, 2019
Facebook Pixel custom tag template for Google Tag Manager
View Facebook Pixel.tpl
"displayName": "Facebook Pixel",
"description": "This is a template prototype for the Facebook Pixel.",
"securityGroups": [],
"id": "cvt_temp_public_id",
"type": "TAG",
"version": 1,
"brand": {
View classlist-string
function() {
// Update this array with the class names
var classes = ['class1', 'class2', 'class3'];
// Fetch elements
var els = document.querySelectorAll('.' + classes.join(',.'))
return [], function(e) {
// Get first matching class name per element
return classes.filter(function(c) {
return e.className.indexOf(c) > -1;
You can’t perform that action at this time.