Skip to content

Instantly share code, notes, and snippets.

View tomfuertes's full-sized avatar

Tom Fuertes tomfuertes

View GitHub Profile

window.dfc

window.dfc is a function that allows you to pass a string and returns an int. This string is persisted via localStorage and available to send to reporting solutions like google optimize server side.

Installation

  1. Paste the inline js function into template.liquid as close to the <head> as possible
  2. Paste the ga additional code into shopify admin -> online store -> prefs -> Google Analytics for tracking experiments
<!DOCTYPE html>
<html>
<head>
<script>
window.start = new Date();
function log(str){
return ()=>{
console.log(str, document.readyState, new Date() - start);
if (document.readyState === 'interactive') {
console.log(document.getElementById('foo').style);
@tomfuertes
tomfuertes / CROmetrics.md
Last active July 18, 2017 16:03 — forked from twalk4821/CROmetrics.apply
Application for CROmetrics remote work

CROmetrics Engineering Application

Thanks for your interest in working with us! To apply:

  • Create a "new gist" (link in github header once you're logged in) with the Raw Text of this .md file (do not fork this gist)
  • Answer the following questions in the spaces provided
  • Send an email to tom@crometrics.com and chris@crometrics.com that includes:
    • A paragraph that tells us a little about yourself and why you are interested in this job
    • A link to your Gist
    • Your desired hourly rate and general availability
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Custom click handler -->
<script>
window.myHandler = function() {
console.log('Click!');
};
</script>
<!-- jQuery -->

Keybase proof

I hereby claim:

  • I am tomfuertes on github.
  • I am tomfuertes (https://keybase.io/tomfuertes) on keybase.
  • I have a public key ASAIVt9k4luLPkhhBtcvs3pVzbyvJgyXtEoni54DFZ96owo

To claim this, I am signing this object:

@tomfuertes
tomfuertes / optimizely-gtm.html
Created June 6, 2016 22:31
Google Tag Manager and Optimizely
<script>
// Curry Optimizely optimizely.activateUniversalAnalytics() into GTM via window.optimizelyGTM
(function() {
window.gtmData = window.gtmData || [];
window.optimizelyGTM = window.optimizelyGTM || {};
var oldObj = window.GoogleAnalyticsObject;
window.GoogleAnalyticsObject = 'gtmtmp';
window.gtmtmp = function(set, dim, val) {
window.optimizelyGTM[dim] = val;
};
@tomfuertes
tomfuertes / landing-page-visitors.js
Created June 2, 2016 18:32
Exclude people via Optimizely Custom Audience based on landing page or pages visited
(function() {
// exclude people who have visited /activity-monitor/
function setCookie(name, value, optDays) {
'use strict';
var expires = '';
if (optDays) {
var date = new Date();
date.setTime(date.getTime() + (optDays * 24 * 60 * 60 * 1000));
<!-- Optimizely Revenue Tracking Code -->
<script type="text/javascript">
window.optimizely = window.optimizely || [];
optimizely.push(['trackEvent', 'conversion', { revenue: {{ total_price }} }]);
</script>
<!-- End Optimizely Revenue Tracking Code -->
@tomfuertes
tomfuertes / smartling-ga.js
Last active August 15, 2016 23:07
Custom Smartling GA Integration
// put this in experiment.js in between force and safe
(function pollForGA() {
var experimentId = 123456789; // TODO: Replace This
// NOTE: no custom dimension so can't set it
if (
window.ga && window.optimizely &&
optimizely.data && optimizely.data.experiments &&
optimizely.variationNamesMap
@tomfuertes
tomfuertes / http2-server-push.rb
Last active February 2, 2019 19:32
Rails HTTP2 Server Push via Header Link (on Cloudflare)
class ApplicationController < ActionController::Base
after_action :server_push_headers # https://twitter.com/connorjshea/status/728472354385317888
def server_push_headers
# CLoudflare HTTP2 Server Push: https://blog.cloudflare.com/announcing-support-for-http-2-server-push-2/
if request.format.html? # only on html pages
layout = self.send(:_layout) # with the right layout
if layout == "main" || layout == "speaker" || layout == "admin"
assets = [