Last active
February 11, 2020 17:55
-
-
Save cbarley10/eaf9f0a0d0f71c10d9a2976a6884ee73 to your computer and use it in GitHub Desktop.
Kind Snacks Register and Login Snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var user = { | |
firstname: "", | |
lastname: "", | |
emailid: "" | |
} | |
var checkExist = setInterval(function() { | |
if ($("form[name='loginradius-registration']").length) { | |
var form = $("form[name='loginradius-registration']")[0]; | |
var registerSubmitButton = $("#loginradius-submit-register"); | |
var loginSubmitButton = $("#loginradius-submit-login"); | |
form.addEventListener("change", function(e){ | |
user[e.target.name] = e.target.value | |
}); | |
registerSubmitButton.addEventListener("click", function(){ | |
// identify user | |
_learnq.push(["identify", { | |
"$email": user.emailid, | |
"$firstname": user.firstname, | |
"$lastname": user.lastname | |
}]); | |
// make track call to create event in Klaviyo | |
_learnq.push(["track", "Registered For Account", {} ]) | |
}) | |
loginSubmitButton.addEventListener("click", function(){ | |
// identify user | |
_learnq.push(["identify", { | |
"$email": user.emailid | |
}]); | |
// make track call to create event in Klaviyo | |
_learnq.push(["track", "Logged Into Account", {} ]) | |
}) | |
clearInterval(checkExist); | |
} | |
}, 100); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment