Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Adding several Google Analytics custom campaign parameters can make URLs very long.*

For example, in Google's own examples:


Are there shorter alternatives that GA will pick up?

* In some implementations, this can be bad for user experience, and could even decrease the likelihood of being shared.

share|improve this question
Why does this matter? Is it actually preventing you from doing something? – Su' Jul 4 '13 at 10:11
@Su', because overly long links can negatively impact UX, with decreased share-ability on social media, online comments, etc. – Baumr Jul 4 '13 at 10:38
up vote 2 down vote accepted

You can, if you are willing to add some additional code to your website. You need to call _setAllowAnchor(true) and add the parameters to a hash query. Here's a proof of concept:

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-XX']);
_gaq.push(['_setAllowAnchor', 'true']); // tell GA to read params from hash
    history.pushState("", document.title, window.location.pathname); // remove hash

var campaign = "spring";
var medium = "email";
var source = "source";
var content = "content";

// add params to hash, if some condition is true
if (true) {
    window.location.href = "#utm_campaign=" + campaign + "&utm_medium=" + medium + "&utm_source=" + source + "&utm_content=" + content;

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);

share|improve this answer
Awesome solution, thanks! – Baumr Jul 4 '13 at 11:28

No, there are no alternatives as of yet, sinceutm_source and utm_medium are required.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.