Skip to content

Instantly share code, notes, and snippets.

@robflaherty
robflaherty / gist:4d61c91ee1d771421c2b
Created October 14, 2015 14:14
Riveted Non-Bounce Example
riveted.init({
eventHandler: function(data) {
if (data == 10) {
ga('send', 'event', 'Non-Bounce', 'True');
}
}
});
@robflaherty
robflaherty / gist:1870a8cd204cf0915ab6
Created August 13, 2015 23:45
remove first line from file
cat input.csv | sed "1 d" > output.csv
@robflaherty
robflaherty / detectIOSMultitask.js
Created June 16, 2015 12:13
Detect iOS 9 iPad Multitask Mode
var detectIOSMultitask = function(callback) {
var inMultitask;
function report(event) {
callback({ event: event, width: document.documentElement.clientWidth, height: document.documentElement.clientHeight });
}
if (navigator.userAgent.match(/iPad/i) == null) {
return;
@robflaherty
robflaherty / gist:ecebc6d0846e7705048b
Created June 15, 2015 20:32
detect-ios-multitask
<script>
detectIOSMultitask(function(data) {
// data.event = 'load', 'enter', or 'exit'
console.log( data['event'], data['width'], data['height'] );
// Example Google Analytics event
ga('send', 'event', 'iOS Multitask', data['event'], data['width'] + 'x' + data['height'], {'nonInteraction': 1});
});
var active = false;
function changeRefer(details) {
if (!active) return;
for (var i = 0; i < details.requestHeaders.length; ++i) {
if (details.requestHeaders[i].name === 'Referer') {
details.requestHeaders[i].value = 'http://www.google.com/';
break;
}
2-1: 13/11, 6/5
3-1: 8/5, 6/5
4-1: 24/23, 13/9
5-1: 24/23, 13/8
6-1: 13/7, 8/7
3-2: 24/21, 13/11
4-2: 8/4, 6/4
5-2: 24/22, 13/8
6-2: 24/18, 13/11
if (document.documentElement.clientWidth < 600) {
jQuery.scrollDepth();
}
var videoPlaying;
var v = document.getElementsByTagName("video")[0];
// When the video starts
v.addEventListener('playing', function() {
// Poll the video every 5 seconds and keep the Riveted timer going
videoPlaying = setInterval(function() {
if (!v.paused) {
riveted.trigger();
<script src="riveted.min.js"></script>
<script>riveted.init();</script>
@robflaherty
robflaherty / Percentage Bookmarklet
Last active August 29, 2015 13:56
This shows the percentage comparison between two advanced segments on the Overview dashboard
javascript:(function(){var%20el=document.createElement('div'),b=document.getElementsByTagName('body')[0];function%20getScript(url,success){var%20script=document.createElement('script');script.src=url;var%20head=document.getElementsByTagName('head')[0],done=false;script.onload=script.onreadystatechange=function(){if(!done%20%26%26(!this.readyState||%20this.readyState=='loaded'||%20this.readyState=='complete')){done=true;success();script.onload=script.onreadystatechange=null;head.removeChild(script);}};head.appendChild(script);}getScript('//code.jquery.com/jquery.min.js',function(){$jq=jQuery.noConflict();$jq('._GAgL').on('click',function(e){var%20$e=$jq(e.target);var%20a=$e.text();var%20b=$e.parents('._GAZt').next('._GAZt').find('._GAgL').text();var%20res=Math.round(parseInt(a,10)/%20parseInt(b,10)*100)+'%25';$e.append('%3Csmall%20style=%22color:%23666%22%3E%20'+res+'%3C/small%3E')});});})();