Skip to content

Instantly share code, notes, and snippets.

// ==UserScript==
// @name Remove loading screen from Google Optimize
// @version 0.1
// @description Script to remove the annoying loading screen...
// @author @simondahla
// @match https://optimize.google.com/optimize/home/
// ==/UserScript==
(function() {
var element = document.getElementsByClassName('opt-busy-dialog')
@simondahla
simondahla / logTimes.js
Last active October 18, 2018 14:13
#googleanalytics
function logTimes(message) {
if (window.performance) {
performance.mark(message); // this one is for WebPageTest
console.timeStamp(message); // this is for the Performance tab in Chrome DevTools
console.info(message, performance.now()); // this is for the console, duh
// this here is for Google Analytics
ga('send', {
hitType: 'timing',
timingCategory: 'Performance',
function onEdit() {
var doc, footer, style = {};
// Define a custom paragraph style.
style[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] = DocumentApp.HorizontalAlignment.RIGHT;
style[DocumentApp.Attribute.FONT_FAMILY] = 'Proxima Nova';
style[DocumentApp.Attribute.FONT_SIZE] = 6;
style[DocumentApp.Attribute.BOLD] = false;
style[DocumentApp.Attribute.ITALIC] = true;
/**
* Function adds style element to the bottom of the head element of the page
* @param {string} code Any string of css code
* @return {undefined}
*/
function insertCssToHead( code ) {
var style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet) {
@simondahla
simondahla / with-analytics.js.html
Last active November 29, 2019 11:24
Updated Instructions for Implementing Google Optimize. Where `GTM-XXXXXX` is the Optimize Container ID & where `GTM-YYYYYY` is the Google Tag Manager Container ID and where `UA-ZZZZZZZZ-Z` is the Google Analytics Property ID. Based on the latest documentation at https://support.google.com/360suite/optimize/answer/7359264
<!DOCTYPE html>
<html>
<head>
<!-- 0. UTF-8 encoding -->
<meta charset="utf-8">
<!-- 1. (OPTIONAL) Move jQuery here. -->
<!-- 2. (OPTIONAL) Datalayer -->
function() {
var vwoExp = null;
if (typeof _vwo_exp !== 'undefined') {
vwoExp = [];
for (keys in _vwo_exp) {
(typeof _vwo_exp[keys]['combination_chosen'] !== 'undefined' ? vwoExp.push(keys + ':' + _vwo_exp[keys]['combination_chosen']) : '');
}
(vwoExp.length > 0 ? vwoExp = '|' + vwoExp.join('|') + '|' : vwoExp = null);
}
return vwoExp;
<script>
(function() {
'use strict';
var o = window.optimizely;
window.optimizely = window.optimizely || [];
window.dataLayer = window.dataLayer || [];
if (o.activeExperiments && o.allExperiments) {
for (var i = 0; i < o.activeExperiments.length; i++) {
var experimentId = o.data.state.activeExperiments[i];
function() {
if (window.optimizely) {
var o = optimizely;
if (o.activeExperiments && o.allExperiments) {
for (var i = 0; i < o.activeExperiments.length; i++) {
<script>
(function() {
var d = false;
window.optimizely = window.optimizely || [];
var o = window.optimizely;
if (o.activeExperiments && o.allExperiments) {
for (var i = 0; i < o.activeExperiments.length; i++) {
var experimentId = o.data.state.activeExperiments[i];
@simondahla
simondahla / optimizely-gtm-custom-integration.js
Last active November 29, 2019 11:23
set d to true for console debugging
(function() {
var d = false;
window.optimizely = window.optimizely || [];
var o = window.optimizely;
if (o.activeExperiments && o.allExperiments) {
for (var i = 0; i < o.activeExperiments.length; i++) {
var experimentId = o.data.state.activeExperiments[i];
var experimentName = experimentId;