Skip to content

Instantly share code, notes, and snippets.

View eduardocereto's full-sized avatar
💩

Eduardo Cereto Carvalho eduardocereto

💩
View GitHub Profile
@eduardocereto
eduardocereto / example.js
Created July 8, 2012 20:48
Simple Class Instantiation Javascript
var User = makeClass();
User.prototype.init = function(first, last){
this.name = first + " " + last;
};
var user = User("John", "Resig");
user.name
// => "John Resig"
@eduardocereto
eduardocereto / .vimrc
Created July 11, 2012 07:02
.vimrc optimized for Python and Javascript
" ==========================================================
" Vundle
" ==========================================================
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
@eduardocereto
eduardocereto / analytics.js
Created October 2, 2012 18:35
GAS firing MaxScroll with sampling
var _gas = _gas || [];
_gas.push(['_setAccount', 'UA-YYYYYY-Y']); // REPLACE WITH YOUR GA NUMBER
_gas.push(['_setDomainName', '.mydomain.com']); // REPLACE WITH YOUR DOMAIN
_gas.push(['_trackPageview']);
_gas.push(['_gasTrackForms']);
_gas.push(['_gasTrackOutboundLinks']);
// Max Scroll on 20% of the pages
if(Math.random() * 100 < 20) {
_gas.push(['_gasTrackMaxScroll']);
@eduardocereto
eduardocereto / README.md
Last active August 2, 2017 15:12
Calculates Traffic Source

Calculates Traffic Source

Still a work in progress, not ready for usage.

Tries to mim Classic Google Analytics methodology to calculate traffic source client side.

On Universal Analytics all this is calculated server side, so it's unavailable in case you need it client side.

@eduardocereto
eduardocereto / ga-track-outbound.js
Last active July 16, 2022 17:19
Outbound Link Tracking
(function(){
// Provides a plugin name and constructor function to analytics.js. This
// function works even if the site has customized the ga global identifier.
function _providePlugin(pluginName, pluginConstructor) {
var ga = window[window['GoogleAnalyticsObject'] || 'ga'];
if (ga) ga('provide', pluginName, pluginConstructor);
}
// Creates the plugin to tag outbound link
function outboundConstructor(tracker, config){