( function ( $, w, d ) {

var jsUTMTrigger_join_trigger = function () {

this.controllerName = "jsUTMTrigger_join_trigger";
this.src = "inc/controllers/js/utm_triggers/";

this.view = window.ct_view_controller;
this.trigger = window.ct_utm_controller_trigger;
this.utm = window.ct_utm_controller;

this.called = false;

this.setupTrigger = function () {
/*
             * Setup after AJAX request actions
             * */
            $( document ).ajaxSuccess( function ( event, xhr, settings ) {
                var params = ct_view_controller.parseRequestParams( settings.data );
                var action = typeof params !== "undefined" ? params.action : 'unknown-action';

                w.jsUTMTrigger_join_trigger.ajaxSuccess__trigger( action + '::success', settings.url, params, xhr.responseJSON );
            } );};

/**
 * Checks the conditions of set parameters and triggers GA call if needed
 */
this.ajaxSuccess__trigger = function ( action, target, params, responseData ) {

    if ( action === "ct_ajax_register_form::success" ) {

var existingMember = typeof responseData.data.existingMember !== "undefined" ? responseData.data.existingMember : false;

var new_member = typeof responseData.data.new_member !== "undefined" ? responseData.data.new_member : false;

if ( existingMember ) {gaEvent( 'member', 'existing', 'join');}

if ( new_member ) {gaEvent( 'member', 'new','join' );}

    }
};;

this.initActions = function () {
if( !this.called ) this.setupTrigger();
this.called = true;
};

this.setState = this.view.setState;
this.reInit = this.view.reInit;
this.init = this.view.init;

return this.init();
};

var regex = /\/wp-json\//gm;
if ( regex.exec( window.location.href ) === null ) {
var controller = new jsUTMTrigger_join_trigger( );
}
} )( jQuery, window, document );