I was struggling with this one for a while and finally got it to work, so I figured I’d share. Other solutions have been posted about running Wix code on logout, but this is specifically for running custom code through Tracking & Analytics.
The logic is simply to run custom code when the Log Out button is clicked.
First, import jQuery in the Head:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
Next, select the element and assign it an onClick function in the Body - End:
<script>
$('#comp-ju1cnv5bmenuItemDiv3').eq(0).on("click", function(){
//insert custom code here
});
</script>
Note: this can obviously be done without jQuery, but this is how I did it.
I’m not sure if the element will be the same for everyone, so this is where I found mine:
Good luck out there.
Steve
1 Like
Yes, however other options are much better as they are using a button for login and logout which is coded separately to a Wix app.
You on the other hand are using the Wix Login Bar which is a feature of the Wix Members app and is technically a closed shop to being integrated with any code from Wix Corvid.
The simple option here is that a lot of people, myself included, don’t use the Wix Login Bar from within the Wix Members app and simply make our own login/logout button which we can have complete control over from the beginning and not have to resort to using html code to make a workaround for using a Wix app feature instead of just simply doing it yourself.
Good previous posts about this here.
https://www.wix.com/corvid/forum/community-discussion/this-is-how-to-logout-and-go-to-the-page-of-your-choice
https://www.wix.com/corvid/forum/community-discussion/redirect-user-on-logout-of-members-area-not-using-a-button
Thanks for all the info! I could not agree more that starting from scratch on the login/logout button is ideal. The option you provided is better.