var gaSuccessHandler = function(result) {
  //  alert('GA initialized: ' + result);
};

var gaErrorHandler = function(error) {
   // alert('GA initialization failed: ' + error);
};

var gaNativePluginResultHandler = function(result) {
   // alert('Event tracked: ' + result);
};

var gaNativePluginErrorHandler = function(error) {
   // alert('Event tracking failed: ' + error);
};

var getGAPlugin = function() {
    if (window.plugins) {
        console.log('GA Plugin found');
        return window.plugins.gaPlugin;
    }
    console.log('GA Plugin NOT found');
};

var initGA = function() {
    console.log('Initialize GA');
    if (getGAPlugin()) {
        getGAPlugin().init(gaSuccessHandler, gaErrorHandler, "UA-55401888-7", 10);
    }
};

var trackPage = function(pageName) {
    console.log("trackPage: " + pageName);
    if (getGAPlugin()) {
        getGAPlugin().trackPage(gaNativePluginResultHandler, gaNativePluginErrorHandler, pageName);
    }
};

var trackEvent = function(category, eventAction, eventLabel, eventValue) {
    console.log("trackEvent: " + category);
    if (getGAPlugin()) {
        getGAPlugin().trackEvent(gaNativePluginResultHandler, gaNativePluginErrorHandler, category, eventAction, eventLabel, eventValue);
    }
};