function sendEmailEventToGa(type, gaToken) {
    var submit = type + "Submit";
    var inputID = type + "Input";

    document.getElementById(submit).addEventListener("click", function () {
        var input = document.getElementById(inputID).value;
        var host = window.location.host;
        var action = type + "-signup";

        ga("create", gaToken, "auto", {
            userId: input
        });

        ga("send", "event", host, action + "-started");

        if(!validateEmail(input)) {
            ga("send", "event", host, action + "-incorect-mail", input);
        } else {
            ga("send", "event", host, action + "-completed", input);
        }
    });
}
function validateEmail(email) {
    var re =
        /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    return re.test(email);
}
