I have been researching online and every website I visit suggests that a function would take a parameter if declared, but for some reason it's not working in my case.
It works fine like this:
<script type='text/javascript'>
function trackSubmit() {
setTimeout(function(){
ga('send', 'event', 'category', 'action', 'link', 4);
}, 100);
}
</script>
And also with:
<form onsubmit="trackSubmit()">
However, when I try something like this, it doesn't work as expected.
<script type='text/javascript'>
function trackSubmit(category, action, link) {
setTimeout(function(){
ga('send', 'event', category, action, link, 4);
}, 100);
}
</script>
<form onsubmit="trackSubmit(testcategory, testaction, testlink)">
I'm at a loss on how to fix this issue. Should I create multiple functions like trackSubmit1, trackSubmit2, etc.? But that wouldn't be very efficient.
Thank you in advance for any assistance.