Skip to content

Instantly share code, notes, and snippets.

@stugoo
Last active December 14, 2015 01:09

Revisions

  1. stugoo revised this gist Feb 21, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion event-tracker-modernizr.js
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ SDM.track = function (args) {
    };


    (function (Modernizr, GoogleAnalyticsQueue) {
    (function (Modernizr) {
    var trackpasses = true,
    trackfails = true,
    trackFeature = function (results) {
  2. stugoo revised this gist Feb 21, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion event-tracker-modernizr.js
    Original file line number Diff line number Diff line change
    @@ -48,4 +48,4 @@ SDM.track = function (args) {

    if( trackpasses || trackfails) return log();

    })(Modernizr, _gaq);
    })(Modernizr);
  3. stugoo revised this gist Feb 21, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions event-tracker-modernizr.js
    Original file line number Diff line number Diff line change
    @@ -41,8 +41,8 @@ SDM.track = function (args) {
    tests.failed.push(d);
    }

    tests.passed = tests.passed.join();
    tests.failed = tests.failed.join();
    tests.passed = tests.passed.join("|");
    tests.failed = tests.failed.join("|");
    trackFeature(tests);
    };

  4. stugoo revised this gist Feb 21, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions event-tracker-modernizr.js
    Original file line number Diff line number Diff line change
    @@ -20,10 +20,10 @@ SDM.track = function (args) {
    trackfails = true,
    trackFeature = function (results) {

    if (trackpasses || results.passed.length > 0)
    if (trackpasses && results.passed.length > 0)
    SDM.track({ category: 'modernizr', action: 'passes', label: results.passed });

    if (trackfails || results.failed.length > 0)
    if (trackfails && results.failed.length > 0)
    SDM.track({ category: 'modernizr', action: 'fails', label: results.failed });

    },
  5. stugoo revised this gist Feb 21, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions event-tracker-modernizr.js
    Original file line number Diff line number Diff line change
    @@ -20,10 +20,10 @@ SDM.track = function (args) {
    trackfails = true,
    trackFeature = function (results) {

    if (trackpasses)
    if (trackpasses || results.passed.length > 0)
    SDM.track({ category: 'modernizr', action: 'passes', label: results.passed });

    if (trackfails)
    if (trackfails || results.failed.length > 0)
    SDM.track({ category: 'modernizr', action: 'fails', label: results.failed });

    },
  6. stugoo revised this gist Feb 21, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion event-tracker-modernizr.js
    Original file line number Diff line number Diff line change
    @@ -37,7 +37,7 @@ SDM.track = function (args) {

    if(Modernizr[d] && trackpasses)
    tests.passed.push(d);
    if ( trackfails )
    else if ( trackfails )
    tests.failed.push(d);
    }

  7. stugoo revised this gist Feb 21, 2013. 1 changed file with 6 additions and 7 deletions.
    13 changes: 6 additions & 7 deletions event-tracker-modernizr.js
    Original file line number Diff line number Diff line change
    @@ -17,15 +17,14 @@ SDM.track = function (args) {

    (function (Modernizr, GoogleAnalyticsQueue) {
    var trackpasses = true,
    trackfails = true,
    trackFeature = function (results) {
    console.log(results);
    trackfails = true,
    trackFeature = function (results) {

    if (trackpasses)
    SDM.track({ category: 'modernizr', action: 'passes', label: results.passed });
    if (trackpasses)
    SDM.track({ category: 'modernizr', action: 'passes', label: results.passed });

    if (trackfails)
    SDM.track({ category: 'modernizr', action: 'fails', label: results.failed });
    if (trackfails)
    SDM.track({ category: 'modernizr', action: 'fails', label: results.failed });

    },
    log = function() {
  8. stugoo revised this gist Feb 21, 2013. 1 changed file with 20 additions and 20 deletions.
    40 changes: 20 additions & 20 deletions event-tracker-modernizr.js
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,7 @@
    /*
    .track via @adamcbrewer
    modernizr from http://jsfiddle.net/ejL3Q/3/
    */
    var SDM = SDM || {};


    var NS = NS || {};

    NS.track = function (args) {
    SDM.track = function (args) {
    args = args || {};

    var category = args.category,
    @@ -21,14 +16,16 @@ NS.track = function (args) {


    (function (Modernizr, GoogleAnalyticsQueue) {
    var trackFeature = function (testName, testResult) {
    var result = (testResult) ? 'Yes' : 'No';
    var trackpasses = true,
    trackfails = true,
    trackFeature = function (results) {
    console.log(results);

    if (trackpasses)
    SDM.track({ category: 'modernizr', action: 'passes', label: results.passed });

    NS.track({
    category: 'modernizr',
    action: testName,
    label: result
    });
    if (trackfails)
    SDM.track({ category: 'modernizr', action: 'fails', label: results.failed });

    },
    log = function() {
    @@ -39,14 +36,17 @@ NS.track = function (args) {
    if(typeof Modernizr[d] === 'array') continue;
    if(typeof Modernizr[d] === 'object') continue;

    if(Modernizr[d])
    if(Modernizr[d] && trackpasses)
    tests.passed.push(d);
    else
    if ( trackfails )
    tests.failed.push(d);

    trackFeature(d, Modernizr[d]);
    }
    return tests;

    tests.passed = tests.passed.join();
    tests.failed = tests.failed.join();
    trackFeature(tests);
    };
    return log();

    if( trackpasses || trackfails) return log();

    })(Modernizr, _gaq);
  9. stugoo revised this gist Feb 21, 2013. 2 changed files with 52 additions and 21 deletions.
    52 changes: 52 additions & 0 deletions event-tracker-modernizr.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    /*
    .track via @adamcbrewer
    modernizr from http://jsfiddle.net/ejL3Q/3/
    */


    var NS = NS || {};

    NS.track = function (args) {
    args = args || {};

    var category = args.category,
    action = args.action,
    label = args.label,
    value = args.value || null;

    if (_gaq) {
    _gaq.push(['_trackEvent', category, action, label, value]);
    }
    };


    (function (Modernizr, GoogleAnalyticsQueue) {
    var trackFeature = function (testName, testResult) {
    var result = (testResult) ? 'Yes' : 'No';

    NS.track({
    category: 'modernizr',
    action: testName,
    label: result
    });

    },
    log = function() {
    var tests = {passed: [], failed: [] };

    for(d in Modernizr) {
    if(typeof Modernizr[d] === 'function') continue;
    if(typeof Modernizr[d] === 'array') continue;
    if(typeof Modernizr[d] === 'object') continue;

    if(Modernizr[d])
    tests.passed.push(d);
    else
    tests.failed.push(d);

    trackFeature(d, Modernizr[d]);
    }
    return tests;
    };
    return log();
    })(Modernizr, _gaq);
    21 changes: 0 additions & 21 deletions event-tracker.js
    Original file line number Diff line number Diff line change
    @@ -1,21 +0,0 @@
    /* via @adamcbrewer */
    track = function (args) {
    args = args || {};
    console.log(args);
    var category = args.category,
    action = args.action,
    label = args.label;
    value = args.value || null;

    if (_gaq) {
    _gaq.push(['_trackEvent', category, action, label,value]);
    }
    };

    /*usage */
    track({
    category: 'Deed',
    action: 'Submit',
    label: ''
    value: '' // Optional
    });
  10. stugoo revised this gist Feb 20, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions event-tracker.js
    Original file line number Diff line number Diff line change
    @@ -17,4 +17,5 @@ track({
    category: 'Deed',
    action: 'Submit',
    label: ''
    value: '' // Optional
    });
  11. stugoo revised this gist Feb 20, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion event-tracker.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ track = function (args) {
    value = args.value || null;

    if (_gaq) {
    _gaq.push(['_trackEvent', category, action, label]);
    _gaq.push(['_trackEvent', category, action, label,value]);
    }
    };

  12. stugoo revised this gist Feb 20, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions event-tracker.js
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,7 @@ track = function (args) {
    var category = args.category,
    action = args.action,
    label = args.label;
    value = args.value || null;

    if (_gaq) {
    _gaq.push(['_trackEvent', category, action, label]);
  13. stugoo revised this gist Feb 20, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions event-tracker.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    /* via @adamcbrewer */
    track = function (args) {
    args = args || {};
    console.log(args);
  14. stugoo created this gist Feb 20, 2013.
    18 changes: 18 additions & 0 deletions event-tracker.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    track = function (args) {
    args = args || {};
    console.log(args);
    var category = args.category,
    action = args.action,
    label = args.label;

    if (_gaq) {
    _gaq.push(['_trackEvent', category, action, label]);
    }
    };

    /*usage */
    track({
    category: 'Deed',
    action: 'Submit',
    label: ''
    });