We’re trying to have a HubSpot’s CTA which we’ll use, not to LINK a user to a specific page or something like that, but rather to open up a modal with additional information.
What we did:
We used a javascript language to prevent default behaviour of that specific CTA ( which is targeted by the class name ). Something like this:
$('.our-cta').on('click', 'a', function(e) {
e.preventDefault();
// OPEN MODAL AND DO SOME OTHER STUFF
})
Issue:
Unfortunatelly, what we saw is that CLICKS count is not being affected and even tough we clicked 15+ times, count is === 0
Does this mean that if we prevent the default behaviour of the CTA, clicks count won’t work? If so, is there any other way around in order to achieve desired effect?
Hmm should work, I just tested the below on a Hubspot CTA that was in one of our blogs and it works. How are you counting clicks? If you’ve defined the variable inside the function, it will never increment.
const btn = document.getElementsByClassName('cta_button')[0];
btn.addEventListener('click', (e) => {
e.preventDefault();
console.log(e.target); //outputs html of Hubspot CTA
});
When I say CLICKS count, I mean the CTA insight within the HubSpot’s dashboard. You navigate to that specific CTA and you can see CLICKS info on how many clicks were there. It’s something that’s caught by HubSpots builtin script, not myself.
“CTA tracking requires the destination URL to have a number of query parameters appended to it, so it’s not the best way to track clicks to open a modal. I’d recommend using your own button and custom events, or potentially another analytics service.”