Last active
July 1, 2018 15:08
-
-
Save ethangardner/7879053f84162abee851 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var track = { | |
google: { | |
event: function(args) { | |
if (typeof ga === "function") { | |
if (args.constructor !== [].constructor) { | |
new Error('This function takes an array as the argument. You passed a ' + typeof args); | |
} | |
else if( args.length < 2 || args.length > 5 ) { | |
new Error('This function needs an array of 2 to 5 items. You passed ' + args.length); | |
} | |
else { | |
args.unshift('event'); | |
args.unshift('send'); | |
ga.apply(this, args); | |
} | |
} | |
} | |
} | |
}; | |
// track.google.event(['Video', 'play', 'Fall Campaign']); | |
// will call ga('send', 'event', 'Video', 'play', 'Fall Campaign'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment