0

trackLink trackForm not working

I am currently successfully using analytics.track to track generic events, but I cannot get either trackLink or trackForm to work.  Even with a simple example such as:

clickLink = () => {
    // analytics.timeout(700);
    const link = document.getElementById(`${idPrefix}ApplicantsLink`);
    console.log(link);
    analytics.trackForm(link, 'generic link', {
        some_prop: 'Some Prop Value'
    });
    console.log(result);
};

The above code throws no errors, but I see no events in the debugging console.  Any ideas?

 

Thanks in advance!

1reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Hey Randall,

    Just solved a similar issue with trackForm. trackLink and trackForm require a DOM Element as the first object. The reason why is because these helpers implicitly set an event listener for you.

    Based on your code, it looks like clickLink might be an event listener callback. If this is true, you must let the helper function set the listener instead of putting it inside your own listener. Make sure you're calling analytics.trackForm outside of an event listener. 

    Reply Upvote 2