Reputation: 125
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 ?
Upvotes: 5
Views: 4966
Reputation: 459
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>
Upvotes: 2
Reputation: 9845
You can use the events tracking API:
<a onclick="javascript:_paq.push(['trackEvent', 'User', 'Login']);">Log In</a>
Upvotes: 4