Code

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 Member Logins preview

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

  1. Add a a New Field on the Forms and Fields page.
  2. Update the Javascript code with the new field name
  3. 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>

                    

Browse similar code snippets

Language

Related Webflow questions

All answers →

Similar code snippets

All code snippets →