How to Remove utm_source & Other Parameters From Your URLs
Have you noticed some unwanted crap being added to website addresses?
Yes, I’m talking about utm_source crap and similar website address pollution!
utm_source crap is usually merely annoying and distracting but it can even break websites.
Yet most of the time the tracking aspects may creep you out due to privacy concerns.
Here are some solutions and explanations how to get rid of unwanted parameters.
How to add gay porn to any site
These days there is a quite common and very annoying habit!
Many services attach utm_source and other so called parameters to your Internet address aka URL.
It’s not only that. The issue is even broader and may be more embarrassing!
Basically anybody can add anything as a parameter to your website address!
Strangers can make it appear as if it’s part of your blog or site.
Outrageous isn’t it? Just try adding
- “?content=gay,porn”
- “?utm_source=ISIS”
- “?you-suck”
to any of your website addresses or links to other sites!
Most sites accept that without even showing an error “not found”.
In case you link such an address Google will even index it.
This way you can make Google show up fake pages that do not even exist on other people’s websites.
Unwanted parameters can cause a lot of harm on your site.
You get unlimited duplicate content this way. Everybody can meddle with your address using parameters.
People share the wrong (polluted) links. Thus you lose juice on social media.
Links can even break because of the added parameters. In the best case they are just confusing.
Who adds utm_source to links and why?
utm_source is added by multiple services in order to track website visitors on Google Analytics.
You get misleading numbers on Google Analytics that way though. That’s why
I do not recommend adding such parameters to website links in the first place.
It backfires even for marketing purposes in manifold ways!
When I click a link on Facebook which is tagged utm_source=Twitter.com it gets wrongly counted as stemming from Twitter and not Facebook.
It is still tagged as Twitter.com even though you shared it and someone visited it on Facebook.
Just because the first share happened on X/Twitter does not mean that Facebook it got shared on later should get no credit.
Also public social media counts often do not add up anymore.
An address with added parameters will get counted as different and separate than the original link.
Websites may lose out on social proof that way.
You can prevent Buffer and other social media automation and tracking tools from adding the utm_source crap.
That’s not enough to remove all other unwanted parameters from your address though.
Thus I wrote this tiny script in JavaScript you can add to your WordPress blog anywhere in the header:
How to remove all unwanted parameters from your site?
This is the actual script I used for years on my blog here.
Then I had to delete the script from my site as it seems WordPress 3.6+ redirection interferes with it.
I’m not even sure. Nobody could help me explain that.
This way spammers who bombarded my blog with requests created countless invisible additional pages.
Delete yours too in case you use WordPress and the same issue appears.
For most people the “additional pages” problem will stay invisible though even if it happens.
I only discovered it because SEO experts found thousands of links from my blog on their link profile using advanced tools.
Thus you can safely use the basic script below on your blog or site.
I still use this script successfully on my custom built static website.
<script language="JavaScript" type="text/javascript">
<!--
var url = self.location.href;
var p = url.indexOf("?");
var str = url;
var parameter = str.slice(p);
if (p >= 1 && parameter.indexOf("p") != 1 && parameter.indexOf("s") != 1)
{
url = str.slice(0,p);
self.location.replace(url);
}
//-->
</script>
I know it’s quite redundant and not very elegant but my JavaScript skills haven’t been used much in the last decade so you are welcome to customize it.
The script basically checks where the parameter starts and removes everything from the URL including the question mark “?”
This signifies the start of the parameters. It then redirects visitors on the client-side to the accurate URL without parameter crap in the address.
In the end people end up on the actual address they should end up from the start.
Don’t let someone else prevent them from reaching their destination by polluting the URL with parameter spam.
The only acceptable parameters are the “p” so that you can still use the post preview function in your WordPress and “s” for the search function.
When you added the script to your site already a link like this one should get redirected:
http://example.com/?you-suck
to the clean address instead.
You can actually still try it on my main website: http://onreact.com/?you-suck
Are there better solutions by now?
Also take note that I have elaborated on the topic of utm_source crap in a more recent post.
There I link to two more sophisticated solutions.
I used both of them, one locally on my Firefox browser and another on this blog here.
They aren’t perfect either though. They just remove utm_source crap but not all other types of polluting parameters.
That way the gay pron would still show up in your address.
Fix utm_source crap in your browser
What happens when the utm_source crap appears on other people’s websites?
There is good news! You can also strip the tracking parameters right in your browser!
How? Simply by using the ClearURLs extension that is available for all major browsers including
I have used it successfully for a while on my Firefox.
There is one pet-peeve though. In case you’re into affiliate marketing those sites may stop working.
Some other sites may not work properly anymore either.
When you solely remove the tracking parameters in your browser other people will still see them on your site.
Also the ?you-suck example is not a tracking parameter and thus it won’t get blocked at all.
Make sure to clean your addresses for everybody not just yourself.
SEO must be bullshit – It doesn’t get removed at your homepage
(tested with Chromium and Firefox)
Marc: LOL, that’s why I quit web development years ago. There’s always an exception that breaks your nice tiny code. I added the exception for the search “s” after adding the example and as SEO starts with “s” as well… OK, it works for the new example. I’ll have to fix the exception of the exception tomorrow.
Dude, that script also won’t stop Google indexing the parameter version, as the spiders won’t follow the javascript.
As to utm parameters, sure maybe its a bit annoying if you come from a campaign and then want to share the link onwards, but I just delete all the utm stuff (which would make throw the stats off anyway)
Also I’ve never seen duplicate content created from Google Analytic parameters, I am pretty sure they speak with the web crawler team to prevent that / and if you want to make doubly sure you could block those parameters off in GWT or other means.
Also, you may want to mention the AllowAnchor GA command, that replaces ? with # so you can keep the tracking without parameters –
http://code.google.com/apis/analytics/docs/gaJS/gaJSApiCampaignTracking.html
But I defo wouldn’t recommend not using utm parameters, they are a very quick n easy way to get metrics for an ROI on campaigns and the benefits far outweigh any inconviencies they may bring, I reckon.
GuavaMarkeD: Yes, that’s true, I forgot to mention that. I’ve done the blocking using GWT for a client just last week.
What I meant is that you can prevent people from linking to the polluted URLs. I guess some people will or alrady have written such a script in PHP with clean 301 redirects etc. My code is for cleaning up the visible URLs and can be used by every blogger without server side skills.
Anyways, thank you for the addition, I will include it in the post.
On the other hand I’m not convinced: IMHO, as I described above, the utm_source parameters make the GA numbers inaccurate as they source isn’t tracked correctly when the referer changes.
Also duplicate content is not just a Google problem, duplicate content on social media is a problem as well as several people bookmark or vote for several URLs insetad of one. Plus even Google can’t know that yoursite.com/?gay.porn is not an actual legit URL.
These URLs are awful for usability as well. Try emailing them. Adding parameters to URLs just for analytics purposes is the wrong way.
Interesting perspective but I’m not so sure this is a good idea. First, just because a tool isn’t perfect doesn’t mean it’s not useful. Two (and more importantly) you offer no alternatives here. Third, yes, I agree there is a flaw in the way some shared links are tagged but to me that’s more of an indication of an opportunity in the market. Hopefully, AddThis or similar will sort it out soon. Given you logic it sounds like URL shorteners are a no no too.
Speaking for myself, I’ve grown a bit tired of emarketers, social media gurus, etc. not measuring their “marketing”. And now you’re actually promoting that idea? Really?
Finally, for an SEO site I’m a bit surprised you picked *those* three examples in the “Just try adding” bit up top. Maybe I’m just being too picky? Also, I think the canonical tag would have been worth mentioning somewhere in there, no?
Thanks for the script, i will add it to my submitshop blog
As for “utm_source”, i have seen it first time few months ago, when they mentioned that linking from blog reviews needs to be monitored for traffic with “utm_source”……
I agree with you that it produce duplicate URL as well as reduce direct benefit of keyword linking from any content based pages
Tad – As usual, you have stirred some good thought and conversation.
I have to ask though, if the canonical tag doesn’t do the same thing without having to add yet another script to the HTML code?
Chief Alchemist: The examples are graphic on purpose to show that it’s not just an issue for hyper advanced SEOs.
It can lead to embarrassment to everybody.
As to measuring social media marketing consider this post:
http://www.bryaneisenberg.com/2010/11/the-true-roi-of-social-media/
I’m a big fan of analytics and measurement but not at the expense of user experience and social media findability.
I’m not sure I understand why you so adamantly support crippling your URLs.
Btw. what do you think about this one:
http://www.chiefalchemist.com/?shop=buy-viagra-online
Kevin: Feel free to use it and thank you for the feedback.
Mike: Very good point. I should have mentioned that. Indeed the canonical tag is a fantastic way to tell the search engines the correct URL but my script tells or rather shows the correct URL to the users so that they can submit it to Delicious etc.
I’ll add your suggestion to the post once I find the time to edit it for good.
In case you need to remove Google’s utm_clutter from URIs with querystrings, there’s an app for that:
http://sebastians-pamphlets.com/stuff/utm-killer/
Thank you!
I think you raised a great issue. Hopefully a future point will address it in a more encompassing fashion.
You’re also right about the tagging. But given the frequency of rouge tagging, I’m not so sure throwing out the baby with the bath water is the way to go.
The fact is, there is an ecosystem of links/shared links – as well as information from the data of such “movement” – yet to the best of my knowledge no one is address that. I appreciate your concern about rouge tags but the lacking of tagging (and measurement) is probably a much bigger problem, eh?
You make some great points but I still think that url queries like ?you-suck aren’t actually that big an issue. I’ve been running my travel blog for a while and I haven’t noticed a single link to a page like this.
Chris: I advise you to look up the parameter section in Google Webmaster Tools and you’ll notice quite a few unwanted parameters in your URLs. Maybe people don’t offend you but many sites and services pollute your URLs.
While it would be nice if Add This sorted the utm_source blah blah from URL’s, it hasn’t as yet. And that means that with the exception of Newsvine, many of the sites that I like to post links to and make comments, or leave for others to make comments, become a cluttered nightmare mess of multi-plates.
The other unpleasantry is the addition of descriptive terms, to the URL as the author mentioned. I DO find this an annoyance, because it can be very embarrassing. I have had it happen two or three times (of which I am aware).
I’ve noticed that some sites use other utm’s, like utma, utmb, utmc. I presume those are cookies?
A few sites, very few (I really want to emphasize that) use utm_a, b,c with values containing my personally identifying information, like my last name or phone number. I don’t know if those utm’s get added onto URL’s, or it is only utm_source. Clearly, I’m no SEO expert.
I’m hoping that is not a valid concern. Tell me that the utm_a, b, c data couldn’t possibly get passed around as part of a URL? Please?
Hey Ellie,
I think you are raising at least two questions: Annoyance and privacy. While all the parameters you see are an annoyance for the user, even copy and pasting an URL becomes an issue, the other thing is private data in the URL.
While utm_a is just another type of parameter (you can name them whatever you want) your URL should not contain private data like your email address. In case it’s in the URL it’s not a cookie. Cookies are not visible in the URL.
Don’t use such services anymore as data in the URL can easily get intercepted by third parties.
Thank you for the explanation. Much appreciated.
Is it really necessary to delete the utm_source? I’m sure that Google is clever enough to realise that there is no duplicate content issues.
I have these problems with my website but I’m not sure that I can be bothered with spending hours trying to fix it if Google does not really care.
Stsan
is there any way to remove them from Webmaster tools..?
Please know that this article is already too long but I need help with this and do not understand what they say to remove the script if using wordpress but, what is the script in wordpress that has that code?
Messenger language = “JavaScript” type = “text / javascript”>
= 1 && parameter.indexOf (“p”) = 1 && parameter.indexOf (“s”) = 1!)
{
url = str.slice (0, p);
car. location.replace (url);
}
/ / ->
Can you tell me what needs to change if wer wordpress?
since my problem is this
http://rsanahuano.com/juicio-y-sentencia/?utm_source=rss&utm_medium=rss&utm_campaign=juicio-y-sentencia
por esto:
http://rsanahuano.com/juicio-y-sentencia/
Hey Roberto!
This script is NOT part of WordPress. I’s a simple JavaSript I added to my blog here and recommended to my readers back in 2010. In case you haven’t added my script originally you don’t have to remove anything.
Sincerely, tad
So what’s the solution here? I can’t see anything informational about this blog. You talking about a script that doesn’t work :D
As of 2017 this issue is still persits ……
Hey Henry!
Thank you for asking!
Indeed the script works but I had to stop using it on WordPress here because somehow spammers found a way to exploit it.
I still use the script on my static site for example.
I have elaborated on the utm_source crap issue in a more recent post though:
http://seo2.0.onreact.com/google-analytics-breaks-links
There you can find links to two more sophisticated solutions. I use both.
One locally on my browser and one on the blog here.
Those fixes aren’t perfect either though.
Sincerely, tad
P.S.: I will update this post to reflect that.