# CTA long url

**URL:** <https://community.hubspot.com/t/cta-long-url/46047>\
**Category:** CMS Development\
**Created:** [October 27, 2021, 5:59pm UTC](https://community.hubspot.com/t/cta-long-url/46047 "2021-10-27T17:59:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![HJack](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/hjack/32/77060_2.png) [@HJack](https://community.hubspot.com/u/HJack)\
**Post date:** [October 27, 2021, 5:59pm UTC](https://community.hubspot.com/t/cta-long-url/46047/1 "2021-10-27T17:59:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [October 28, 2021, 3:02pm UTC](https://community.hubspot.com/t/cta-long-url/46047/2 "2021-10-28T15:02:36Z")

</div>

@Indra , @daveroma : any thoughts here?

---

<div class="post-metadata">

**Author:** ![Indra](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/indra/32/98381_2.png) [@Indra](https://community.hubspot.com/u/Indra)\
**Post date:** [October 29, 2021, 6:37am UTC](https://community.hubspot.com/t/cta-long-url/46047/3 "2021-10-29T06:37:20Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![HJack](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/hjack/32/77060_2.png) [@HJack](https://community.hubspot.com/u/HJack)\
**Post date:** [November 1, 2021, 4:19pm UTC](https://community.hubspot.com/t/cta-long-url/46047/4 "2021-11-01T16:19:18Z")

</div>

Hi @Indra , thanks for your reply!

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

---

<div class="post-metadata">

**Author:** ![Indra](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/indra/32/98381_2.png) [@Indra](https://community.hubspot.com/u/Indra)\
**Post date:** [November 3, 2021, 8:34am UTC](https://community.hubspot.com/t/cta-long-url/46047/5 "2021-11-03T08:34:01Z")

</div>

@HJack,

I can’t fully explain how to setup the GTM, but on there are plenty tutorials on [YouTube](https://www.youtube.com/results?search_query=gtm+button+click+tracking) how yopu can setup these [button click tracking for Google Tag Manager](https://www.youtube.com/results?search_query=gtm+button+click+tracking).

If you don’t know the basics of Google Tag Manager, I suggest to first check simple tutorials on [YouTube](https://www.youtube.com/results?search_query=gtm).

Hope this will help.

---

<div class="post-metadata">

**Author:** ![Jatin-k-rajput](https://avatars.discourse-cdn.com/v4/letter/j/3be4f8/32.png) [@Jatin-k-rajput](https://community.hubspot.com/u/Jatin-k-rajput)\
**Post date:** [March 14, 2024, 11:47am UTC](https://community.hubspot.com/t/cta-long-url/46047/6 "2024-03-14T11:47:45Z")

</div>

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 !
