Long Page URLs In Internet Explorer Cause Missing Pageviews, Transactions In Google Analytics

May 15, 2014 | Jon Meck

While we are known best for our blog content, the vast majority of our time goes towards helping clients with Google Analytics implementation. Our clients often come to us with some form of existing Google Analytics, and it’s our job to sift through the data to make sure everything is being collected correctly. For a website with eCommerce, this involves comparing data from GA to a back-end sales system to make sure everything matches. We’ve found many strange and buggy scenarios, but one in particular stands out as a particularly difficult challenge.

The Longest Place Name

In the scenario below, a client’s website appended an internal key as a query parameter to transaction pages to help with their processing. These keys were huge and the page URLs would sometimes hit 1400 or 1500 characters. When a hit gets sent to Google Analytics, all of the details about the page and the visitor are combined together into one long image request which gets sent to their server. However, Internet Explorer, and more specifically, Internet Explorer 9, imposes a cap on the length of these requests. Because the page URLs were so long, some hits to Google were just failing at the browser level and never made their way to GA.

Continue reading for a “chart review” of how we diagnosed the issue, and then further on for steps on how to fix this for yourself!

Chart Review: The Missing Data in IE

Presenting Symptom: Transactions for Certain IE versions were missing entirely

For this particular client, we compared numbers from their back-end system to the eCommerce data that had been collected in GA. The challenge was to diagnose whether it was a technical issue with the website, or rather an issue with the particular Google Analytics implementation. For this type of analysis, it’s important to use an Unfiltered View. We immediately found that some transactions were being excluded via filters and took steps to address that.

But that didn’t fix the whole issue; there were still transactions missing. We then started digging deeper into the differences between transactions that had made it into GA, and those that hadn’t. We created Advanced Segments using Regular Expressions to be able to segment out these two distinct groups and compare reports. We scoured the Audience reports in GA, trying to find commonalities. Finally, the picture became a little more clear. The missing transactions were almost all from IE visitors and most of them from IE9. Something about IE9 was preventing transactions from even being sent to GA.

I’ll spare you most of the things we checked, but go ahead and imagine a montage sequence with furious typing, head scratching, coffee drinking, and an IE voodoo doll. Lightning finally struck when we tried to compare page paths for the missing transactions with page paths for the collected transactions. For the IE9 transactions in question, the Confirmation pages were just… missing.

Chart Review

Diagnosis: Long URLs Were Causing Image Requests to Fail

As I mentioned above, we figured out that it was this perfect storm of really, really long URLs coupled with IE9’s particularly strict URL limit that was causing these hits to fail.

Here is an interesting Stack Overflow answer about URL length limits in browsers, and then the official Internet Explorer documentation.

The part that made this difficult to diagnose is that each URL hit contains additional information besides just the URL. So many of the hits would sneak through, while others would just never make it.

Treatment: Change the document “location” before sending the hit

How do you fix the problem without changing the website? Once the page gets to Google Analytics, it’s easy to strip off query parameters using the View settings or custom Filters. In this case though, we needed to remove that particular query parameter BEFORE we sent the hit.

Luckily, we can do this by setting a custom location, then sending the GA hit. It’s important to note that in Universal Analytics, changing the document “path” will only change how the URL appears in Google Analytics, but it won’t change the location that is sent along with the hit.

How to Correct the Issue

Fixing the URL

You can go about fixing the URL in a few different ways.  The best way would be to fix this server-side and get rid of those really long URLs. If that’s not possible, then most likely you’re going to need some JavaScript.  Does this issue occur on every page, or is it just specific pages like a checkout page? Google Tag Manager will make it easier, but it might make sense to create a separate Pageview Tag for the pages with the long URLs. Here is a macro that you can use in Google Tag Manager, or adapt to use on your site. For us, the parameter was always at the end, so we just chopped off the URL once we reached that particular parameter.

    url = {{url}};
    limit = url.indexOf("&longparam");
    shortversion = url.substr(0,limit);
    return shortversion;

Setting the Document Location

Use the following steps to correct the issue in Universal or Classic, or if you’re using Google Tag Manager for either.

Universal Analytics:  ga(‘set’,’location’,shortenedUrl);  set this before you send your pageview

Universal Analytics + Google Tag Manager: under Fields to Set, enter “location” and the macro.

Tag Manager Set Location

Classic Analytics: _gaq.push([‘_trackPageview’, shortenedUrl]); this URL is used for the Location and the Path

Classic Analytics + Google Tag Manager: under Basic Configuration, check Virtual Page Path and enter your macro there.

Virtual Page Path Classic

Hopefully, you never come across this issue – but in case you do, now you have the tools to fix it!