Google event tracking

Posted: August 30th, 2011 | Author: | Filed under: JavaScript | No Comments »
$(document).ready( function() {
    // add an event to all link for google analytics
    $('a').click(function () {
        // tell analytics to save event
        try {
            var identifier=$(this).attr('id') ;
            var href=$(this).attr('href')
            var label="";
            if ( typeof( identifier ) != 'undefined' ) {
                label=label+'[id]:'+identifier
                category='JSLink'
            }
            if ( typeof( href ) != 'undefined' ) {
                label=label+' [href]:'+href
                if ( href[0] == '#' ) {
                    category='Anchor';
                } else {
                    category='Link';
                }
            }
            _gaq.push(['_trackEvent', category, 'clicked', label]);
            // console.log('[tracked]: ' + category + ' ; clicked ; ' + label );
        }
        catch (err) {
            // console.log(err);
        }

        // pause to allow google script to run
        var date = new Date();
        var curDate = null;
        do {
            curDate = new Date();
        } while (curDate-date < 300);
    });
});

Source: External blog


Make JavaScript calls within ActionScript 3

Posted: August 30th, 2011 | Author: | Filed under: JavaScript | No Comments »
import flash.external.ExternalInterface;
var returnedValue:int = ExternalInterface.call("foobar()", "argument");

Learn Vim Progressively

Posted: August 30th, 2011 | Author: | Filed under: Development, Linux | No Comments »

Source


Best practice for loading jquery, and other JavaScript libs

Posted: August 4th, 2011 | Author: | Filed under: Development, JavaScript | No Comments »
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/VERSION.NUMBER/jquery.min.js"></script>
<script type="text/javascript">window.jQuery || document.write('<script src="js/jquery.js" type="text/javascript">\x3C/script>')</script>