How to use urlencoded urls with the GA tracking code

Posted by Fake51 on Stack Overflow See other posts from Stack Overflow or by Fake51
Published on 2011-01-06T08:48:17Z Indexed on 2011/01/06 8:54 UTC
Read the original article Hit count: 180

Filed under:

I've got a site where a booking page has an iframe embedded with the actual booking form. I need to track traffic from the parent site to the child iframe. This should all work just fine with the normal GA code, using javascript like:

<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("<UA CODE HERE>");
pageTracker._setDomainName("none");
pageTracker._setAllowLinker(true);
pageTracker._setAllowHash(false);
pageTracker._trackPageview();
} catch(err) {}</script>

And then ofcourse using the _getLinkerUrl() function to get a url with the proper parameters.

So far so good - this basically works (at least I know the principle works as I've got it working on other pages). However, and this is the problem: the server that serves up the page in the iframe was configured by a complete and utter moron (or, alternatively, created by a complete and utter moron). It chokes on '=' characters, so in order to request the iframe page I need to urlencode the '=' signs - but the GA code seems unable to parse the url when this is done.

So the questions: 1. has anyone come across this? 2. does anyone know of any solutions to this problem?

© Stack Overflow or respective owner

Related posts about google-analytics