CMS Development

HJack
Participant

CTA long url

Résolue

Hi,

The CTA links appear to be a long text with tracking parameters and I don't want it. Is there a way to track not through CTA buttons - but through the JS code?

 

Thanks

0 Votes
2 Solutions acceptées
Indra
Solution
Guide | Partenaire solutions Elite
Guide | Partenaire solutions Elite

CTA long url

Résolue

@dennisedson, thanks for mentioning!

 

Hi @HJack,

 

The first question is, why don't you want to have long urls inside your CTA?

The CTA from HubSpot needs to have these parameters to track events.

I don't think you can disable it, since it won't have the effect of tracking.

 

If you don't want the long url, you can make your custom CTA's within by building a custom module.

For tracking you can use multiple ways to track this like:

- Adding UTM tags to every link

- Setup GTM and specify the CTA's

 

In my opinion, you sould build custom CTA's witin your modules. You don't need to track every CTA on every section that will link to internal pages unless it's a landingpage. HubSpot CTA's will add javascript that will slow down your page that can effect website performance.

 


Vet Digital - The Growth Agency | HubSpot Solutions Partner Agency

Did my post solve your question? Help the community by marking it as a solution

Voir la solution dans l'envoi d'origine

Indra
Solution
Guide | Partenaire solutions Elite
Guide | Partenaire solutions Elite

CTA long url

Résolue

@HJack,

 

I can't fully explain how to setup the GTM, but on there are plenty tutorials on YouTube how yopu can setup these button click tracking for Google Tag Manager.

 

If you don't know the basics of Google Tag Manager, I suggest to first check simple tutorials on YouTube.

Hope this will help.


Vet Digital - The Growth Agency | HubSpot Solutions Partner Agency

Did my post solve your question? Help the community by marking it as a solution

Voir la solution dans l'envoi d'origine

5 Réponses
Jatin-k-rajput
Membre

CTA long url

Résolue

Hi Jack , Apply this in main JS file.
via using this JS you can shorten the url (Replace the CTA class if different i belive you don't need to change anything)
// Get all links with class 'cta_button' var linkscta = document.querySelectorAll('a.cta_button'); // Loop through all links and add a click event listener for (var i = 0; i < linkscta.length; i++) { linkscta[i].addEventListener('click', function(event) { // Prevent the default link behavior event.preventDefault(); // Get the link's href var href = this.getAttribute('href'); // Remove any HubSpot tracking parameters from the href href = href.replace(/\?__hstc=.+&?/, '?'); href = href.replace(/&__hssc=.+&?/, '&'); href = href.replace(/&__hstc=.+$/, ''); href = href.replace(/([&?])hsCtaTracking=([^&%]*(%7C[^&]*)?)/, '$1'); // href = href.replace(/[?&]utm_(source|medium|campaign|term|content)=[^&#]+/gi, ''); // href = href.replace(/[?&]fbclid=[^&#]+/gi, ''); // href = href.replace(/[?&]utm_(source|medium|campaign|term|content)=twitter[^&#]+/gi, ''); // href = href.replace(/[?&]utm_(source|medium|campaign|content)=linkedin[^&#]+/gi, ''); // Navigate to the new URL window.location.href = href; }); }


Thanks !

0 Votes
Indra
Solution
Guide | Partenaire solutions Elite
Guide | Partenaire solutions Elite

CTA long url

Résolue

@HJack,

 

I can't fully explain how to setup the GTM, but on there are plenty tutorials on YouTube how yopu can setup these button click tracking for Google Tag Manager.

 

If you don't know the basics of Google Tag Manager, I suggest to first check simple tutorials on YouTube.

Hope this will help.


Vet Digital - The Growth Agency | HubSpot Solutions Partner Agency

Did my post solve your question? Help the community by marking it as a solution
Indra
Solution
Guide | Partenaire solutions Elite
Guide | Partenaire solutions Elite

CTA long url

Résolue

@dennisedson, thanks for mentioning!

 

Hi @HJack,

 

The first question is, why don't you want to have long urls inside your CTA?

The CTA from HubSpot needs to have these parameters to track events.

I don't think you can disable it, since it won't have the effect of tracking.

 

If you don't want the long url, you can make your custom CTA's within by building a custom module.

For tracking you can use multiple ways to track this like:

- Adding UTM tags to every link

- Setup GTM and specify the CTA's

 

In my opinion, you sould build custom CTA's witin your modules. You don't need to track every CTA on every section that will link to internal pages unless it's a landingpage. HubSpot CTA's will add javascript that will slow down your page that can effect website performance.

 


Vet Digital - The Growth Agency | HubSpot Solutions Partner Agency

Did my post solve your question? Help the community by marking it as a solution
HJack
Participant

CTA long url

Résolue

Hi @Indra , thanks for your reply!

 

How can I specify the CTA by setting up the GTM?

0 Votes
dennisedson
Équipe de développement de HubSpot
Équipe de développement de HubSpot

CTA long url

Résolue

@Indra@daveroma : any thoughts here?

0 Votes