#Track button clicks

2 messages · Page 1 of 1 (latest)

frigid pelican
#

Hello you lovely Scrimba people. I need to be able to record how many times a button is clicked on a site I just produced.
The code is: document.getElementById('btn-calc').addEventListener('click', (e) => {
e.preventDefault();
I searched for days and haven't found the answer yet, other than to learn Google Analytics.
Help greatly appreciated. My dogs will thank you too - they want to go out.

timid gate
#

@frigid pelican Have a global variable that stores the number of clicks, then every time the button is clicked, increase the count by 1