How to 'Strip' utms for clean URLS without screwing up bounce rate?

I must strip utms for clean urls WITHOUT screwing up bounce rate.

For example:

  1. User clicks on link from (ad|seo|page|referreal|socialmedia|bitly)
  2. User lands on https://www.mywebsite.com/page-topic/page-name?utm_source=webflow.com&campaign=om-nom-nom-nom&htid=123456789abcdefg#anchor-link
  3. User should see: https://www.mywebsite.com/page-topic/page-name#anchor-link

What the client wants is

  1. the user to see https://www.mywebsite.com/page-topic/page-name#anchor-link - in the uri bar
  2. able to track it in analytics
  3. says urls looks ugly and makes customers suspicious (because customer on phone was confused by url utms)
  4. Do not redirect to natural uri path because it screws up bounce rate (changes bounce rate from 70% to 0.0%)
  5. Lots of news & media websites do this

I say can try to test it with a redirect, but do not think redirect is correct way to do this because it messes up bounce rates

What is the script to stripe out UTMS from uri bar? How to properly apply it sidewide to webflow project? - Still needs to track anaytics, work on vwo expressions, and crazy egg url match query

like this perhaps?

<script>history.replaceState(null, document.title, location.href.replace(/\?[^#]*/, ''));</script>

put this in the footer so that GTM/analytics code runs first

1 Like

@samliew thanks, i’ll try it out

Let me know how it goes, I’m interested to find out