Reputation: 219
I am using Komito Analytics to track Events in Google Analytics. So far they are doing good. I would like to create 2 different buttons with different ids or classes and track them separately. is that possible?
Upvotes: 2
Views: 80
Reputation: 7369
Depending on your needs and current implementation, you can use one of the following methods:
trackForms
to track forms submissions and wrap each button in a <form>
element:<form onsubmit="return false">
<button type="submit" name="action1">Button 1</button>
<form>
<form onsubmit="return false">
<button type="submit" name="action2">Button 2</button>
<form>
trackActions
to track CTA actions for links and use links instead of buttons:<a href="javascript:void('action1')">Links 1</a>
<a href="javascript:void('action2')">Links 2</a>
or
<a href="javascript:'action1';void 0">Links 1</a>
<a href="javascript:'action2';void 0">Links 2</a>
Upvotes: 2
Reputation: 785
You can count the number of clicks on the button with Javascript
<button id="komito">komito</button>
<script type="text/javascript">
var count = 0;
var btn = document.getElementById("komito");
komito.onclick = function () {
count++;
console.log(count);
}
</script>
Upvotes: 0