Track Member Logins
Track the number of times a user logins or logs out of their Webflow Memberstack account page. This script will allow you to update a Member field of your choosing based on the number of times they have logged into their account.
Track the number of times a user logins or logs out of their Webflow Memberstack account page. This script will allow you to update a Member field of your choosing based on the number of times they have logged into their account.
How to add it
- Add a a New Field on the Forms and Fields page.
- Update the Javascript code with the new field name
- Add the Javascript code to the closing body custom code section
The code
Javascript
<!-- Add to body close section -->
<script>
MemberStack.onReady.then(function(member) {
if (member.loggedIn == true){
// If this is the member's first visit, then set visits=1 in metadata.
if (!metadata.visits){
var memberActions = {
visits: 1
}
}
// If visits already exists, increment its value
else {
var oldValue = metadata.visits;
var newValue = oldValue + 1;
memberActions = {
visits: newValue
};
}
member.updateMetaData(memberActions)
}
})
</script>