Skip to content

Instantly share code, notes, and snippets.

View google-optimize-loading-screen-fix.js
// ==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 Oct 18, 2018
#googleanalytics
View logTimes.js
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',
View addTimestamp.gs
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;
View insert-css-to-head-for-google-optimize.js
/**
* 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 Nov 29, 2019
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
View with-analytics.js.html
<!DOCTYPE html>
<html>
<head>
<!-- 0. UTF-8 encoding -->
<meta charset="utf-8">
<!-- 1. (OPTIONAL) Move jQuery here. -->
<!-- 2. (OPTIONAL) Datalayer -->
View VWO-GTM-GA-integration.js
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;
View optimizely-ga-gtm-integration-with-event-and-custom-dimension.html
<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];
View CM7:8-optimizely-gtm-google-analytics-cd-integration.js
function() {
if (window.optimizely) {
var o = optimizely;
if (o.activeExperiments && o.allExperiments) {
for (var i = 0; i < o.activeExperiments.length; i++) {
View CM7:8-custom-optimizely-gtm-integration.html
<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 Nov 29, 2019
set d to true for console debugging
View optimizely-gtm-custom-integration.js
(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;