Hi there,
I have the following code which I would like to use to track click events:
<script type="text/javascript">
function trackOutboundLink(link, category, action) {
try {
dataLayer.push({'event':'interaction','eventCategory': category,'eventAction':action,'eventLabel': ''});
} catch(err){}
setTimeout(function() {
document.location.href = link.href;
}, 100);
}
</script>
<input type="submit" name="submit" value="Submit" class="submit-button" onClick="trackOutboundLink(this, 'Contact', 'Signup', 'New Signup');" />
However, when the form is submitted, it causes an error by going to a dynamically generated URL. I've been told this is because the setTimeout function is looking for a link, not a button. I have removed the setTimout and the form submits properly.
Is there a way I can have the setTimeout function to use an input instead of a link? Or if I just remove the function, will the event still be tracked?
Thanks!