Get Rid of the URL Pollution

August 13, 2014

You want to copy the URL of a nice article/video/picture you’ve just opened and send it to friends in skype chats, whatsapp, other messengers or social networks. And you realize the URL looks like this:

What are these parameters that pollute the URL? The above example uses some of the Google Analytics parameters (utm*), but other analytics tools use the same approach. And probably other tools as well. How are these parameters useful? They tell Google Analytics (which is run with javascript) details about the current campaign, probably where the user is coming from, and other stuff I and especially users don’t really care about.

And that’s ugly. I myself always delete the meaningless parts of the URL, so that in the end people see only “”. But that’s me – a software engineer, who can distinguish the useless parts of the URL. Not many people can, and even fewer are bothered to cut parts of the URL, which results in looong and ugly URLs being pasted around. Why is that bad?

  • website owners have put effort in making their URLs pretty/ With “url pollution” that efforts goes to waste.
  • defeating the purpose of the parameters – when you copy-paste such a url, all the people that open it may be counted as, for example, coming from a specific AdWords campagin. Or from a source that’s actually wrong (because they got the URL in skype, for example, but utm_source is ‘facebook’)
  • lower likelihood of clicking on a hairy url with meaningless stuff in it (at least I find myself more hesitant)

If you have a website, what can you do about this URL pollution, without breaking your analytics tool? You can get rid of them with javascript:

    window.history.replaceState(null, null, 
        window.location.href.replace("utm_source=....", ""));

This won’t trigger fake analytics results (for GA, at least, as it requires manual work to trigger it after pushState). Now there are three questions: how to get the exact parameters, when to run the above code, and is it worth it?

You can get all parameters (as shown here) and then either remove some blacklisted ones (utm_source, utm_campagin, etc.), or remove all, unless your whitelisted parameters. If your application isn’t using GET parameters at all, that’s easy. If it is, then keeping the whitelist in sync would be tedious, so probably go for the blacklist.

When should you do that? A little after the page loads, and the analytics tool does its job. When exactly is that – I don’t know. Maybe on window.load, maybe you have to wait for a second and then remove the parameters. You’d have to experiment.

And is it worth it? I think yes. Less useless parameters, less noise, nicer, friendlier URLs (that’s why you spent time prettifying them, right?), and less incorrect analytics results due to copy-pasted long URLs.

And I have a request to Google and all other providers of similar tools – please cleanup your “mess” after you read it, so that we don’t have to do it ourselves.

Share Button

20 Responses to “Get Rid of the URL Pollution”

  1. Use replaceState instead of pushState, otherwise you’ll break the Back button!

  2. Thanks, fixed

  3. Thanks for the tip! Although I am too lazy to clean up the URLs I usually send over Skype, this is a good way to keep my analytics correct.

  4. I’ve said this before 🙂 But your own blog uses:

    Why not add category / title into your own URLs?

  5. 😉 I’m not necessarily a fan of having the title in the URL, it was just an example (it’s a configuration switch in wordpress, I think; I’ll consider it 🙂 )

  6. Is it possible to change the color of the bad parts of the URL and leave the good parts of the URL in visible color. I think this is best solution, but not all browser have API to change URL color. It require combinatorial colaboration between browser factory at Msoft and Googles.

  7. Thanks for every other informative web site. The place else
    may I am getting that type of information written in such an ideal approach?

    I’ve a undertaking that I’m simply now working on, and I’ve been on the look out for such

    Feel free to surf to my web site – Online blogs

  8. This isn’t to say that if you’re youthful than 21, you will not
    find an insurance coverage – because you can –
    but will probably be more expensive and tough.

    Feel free to visit my web-site wifehoods (

  9. Thanks , I have just been looking for info about this topic
    for a long time and yours is the best I have found out till now.
    But, what about the conclusion? Are you certain concerning the source?

  10. Awesome post.

    My site …

  11. Useful info. Lucky me I discovered your
    website accidentally, and I am stunned why this coincidence
    did not happened earlier! I bookmarked it.

  12. You’ll be able to simply realize some nice deals on the online, and benefit of them Still, watch out that
    you simply area unit creating the correct call before finalizing.
    This can mean they will have to travel capital t fulfill ankle rehab ebook or even use meeting amenities to keep conferences as well as symposiums.
    In most cases the earlier you book your room the less expensive it will be, and the better your
    chances of getting the room and location that you want.

  13. Good post! We are linking to this great content on our site.
    Keep up the good writing.

  14. I’m amazed, I must say. Rarely do I encounter a blog that’s both equally educative and entertaining, and
    without a doubt, you have hit the nail on the head.
    The problem is something which not enolugh men and women are speakin intelligently about.
    I am very happy I found this during my hunt for something concerning this.

  15. When I originally commented I clicked the “Notify me when new comments are added”
    checkbox and now each time a comment is added I get four emails wjth the same
    comment. Is there any way you can remove peeople from that service?

  16. It’s actually a nice and helpful piece of info.
    I’m satisfied that you just shared this helpful info with
    us. Please keep us up to date like this. Thank you for sharing.

  17. Today, while I was at work, my cousin stole
    my iphone and tested to see if it can survive a thirty
    foot drop, just so she can be a youtube sensation. My apple ipad is now broken and she has 83 views.
    I know this is entirely off topic but I had to share it with

  18. That is a good tip especially to those new to the blogosphere.
    Simple but very precise info… Thanks for sharing this one.
    A must read post!

  19. What a stuff of un-ambiguity and preserveness of precious familiarity concerning unexpected feelings.

  20. Cool blog! Is your theme custom made or did you download it from somewhere?
    A theme like yours with a few simple tweeks would really make my blog shine.
    Please let me know where you got your theme. Kudos

Leave a Reply