I have integrated Piwik in my web site, where I want to track successful and unsuccessful logins. The successful login will redirect the user to Home page, where as on unsuccessful it will redirect to Login Page. Now, If I am trying to send request to Piwik, but mean while it redirects the page to Home /Login.
Can anyone tell me, how I can handle this situation ?
You can use the events tracking API:
<a onclick="javascript:_paq.push(['trackEvent', 'User', 'Login']);">Log In</a>
If you are using jQuery you could alternately do something like this. Even though the user is clicking a link and leaving the page it should still record the event since the requests are sent in parallel.
<body>
<div class="menu">
<ul>
<li><a href="/login">Login</a></li>
</ul>
</div>
</body>
<script>
$(function() {
$('.menu li > a').click(function() {
_paq.push([ 'trackEvent', 'Menu', 'Click', $(this).text() ]);
});
});
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With