Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove /?fbclid=... in nuxt url

hello there i like to remove the facebook analytic forced url parameter /?fbclid= https://www.example.com/?fbclid=..., from my host url, when redirected from facebook by clicking the url, the problem is the nuxt-link-exact-active class is not applied if redirected with this parameter. Thanks


1 Answers

In simple cases like https://www.example.com/?fbclid=... where fbclid is the only parameter, it should be a trivial Javascript like that:

 <script>
  // ideally this is on top of page; works on bottom as well

  if(/^\?fbclid=/.test(location.search))
     location.replace(location.href.replace(/\?fbclid.+/, ""));

 </script>

This checks if ?fbclid=... is a URL search parameter and navigates to the same location with that part removed.


It may also be fine to remove any search parameter and not checking for fbclid.
 <script>
   if(location.search) location.replace(location.href.replace(/\?.+/, ""));
 </script>
like image 169
j.j. Avatar answered Oct 21 '25 14:10

j.j.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!