I need to track a dynamic button that sends the user to another url, depending on the product he is. Something like pinterest. The website is in PHP.

I'm having problems tracking how many user clicked on the button. Tried Piwik, Google, Clicky, Mixpanel and Kissmetrics. Everyone gives different data. For what I've been searching some users say it's a javascript problem because outbound timing. Also tried with a sendmail function, but it sent an email everytime the user visited the product, not everytime he clicked on the button

Is there an easy way to track those clicks inside my site without using any of those metrics services? I just need to track 2 things:

  • url (where is sending the user)
  • clicks (number of clicks)
有帮助吗?

解决方案

This sounds like you sould just have to send an ajax request to the server (assuming you defined the global variable clicks

var url = 'yourUrl';

clicks++;

$('#yourBtn').click(function() {
$.ajax({
   data: {url: url, clicks: clicks},
   url: 'ajax/test.html',
   success: function(data) {
     alert('Load was performed.');
   }
 });
});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top