Google Analytics Configuration Mistake #2: Query String Variables

In my previous post I discussed how an incorrect Default Page setting can cause a single page on your website to be counted as two different pages. That same concept is the driving force behind Common Google Analytics Configuration Mistake #2. If your website uses query string parameters you may be creating hundreds or thousands of unique page views which don’t actually exist.

Google Analytics creates a unique page view using the path name, the file name and any query string parameters present in the location bar of the browser. Remember, the query string parameters are all the junk after the question mark. GA strips the domain name from the URL and the remaining info becomes a unique page.

This URL:

Results in this page view:


And this URL:

Results in this page view:


Now, if the query string parameters passed between pages have no functional significance, i.e. they do not influence the content that is shown to the user, they should be ignored when GA creates a unique page view. Because the query string parameters do not offer any insight into what the visitor is doing, we want GA to track the above URLs as two views to a single page, not two views for two different pages.

The concept here is that the query string parameters do not tell us anything about the visitor’s actions. If your query string parameters describe what the visitor is doing then you do not want to remove them. Example, if one of your query string parameters is a product ID then you would not want to remove it. You want to know which products a visitor views during their session.

To force GA to skip certain query string parameters when processing we enter the unwanted parameters in the ‘Exclude URL Query Parameters:’ filed in the ‘Main Website Profile Information’ section.


Just enter a comma separated list of the parameters in the field I’ve outlined above. Here’s an example:


If your site uses query string parameters to pass ANY information, I recommend you audit all query string parameters and identify which ones can be ignored. Here’s a tip, use the Top Content report to quickly identify the website query string parameters. When you pull up the Top Content report use the in-report-filter and enter \?. This will immediately display all the records containing query string parameters.

Remember, this is going to affect other parts of Google Analytics. Once you add a query string parameter to the list, it will be completely ignored. It will not be listed in ANY of the GA reports. Also, when you exclude a query string parameter you no longer need match that variable when creating goals and funnels.

As usual, changing this setting will not affect the data that has already been processed by Google Analytics. Only data processed in the future will reflect this change.

Be Sociable, Share!

    Like this post? Sign up to get posts delivered to your inbox.


    1. says

      Hi Justin,
      With respect to query string variables, I noticed you made the following comment in an older post:

      “Measuring internal site search with Google Analytics is possible. However, it depends on your website architecture. To track internal search terms with Google Analytics your internal search engine must pass the search term entered by the user in the query string. Google Analytics captures all of the data in the location bar of the browser, including the query string. If the search term is missing from the query string then GA will not be able to track it.”

      What happened to the URI? I have a situation where search terms are not passed via the URL, but I wanted to pass them via the URI and then eventually see conversion data based on site search terms. I take it that the URI won’t be of any service for the Site Search tracking, but is there a way to extract the searched terms and put them in the User Defined variable, while still capturing all page views during a user session. I find that any filters that I write to capture the search terms will ultimately exclude other page views from the profile, thus I am at a bit of an impass.

      Many thanks for any input!


    2. says

      Hi Robert,

      Sorry for the confusion. The URI contains query string parameters. It sounds like you you need to create virtual pageviews using urchinTracker() (or pageTracker.trackPageview() ). When you use these functional you create a new Request URI which GA sees as a standard pageview.

      You can create the pageview on the click of a button or when the search results page loads in the visitor’s browser.

      Hope that helps,


    3. Mike says

      I have been looking for an effective way to create a profile which ignores all query parameters. With the help of an Excel macro that I discovered (possibly on another post on this site?) I found that there were about 200 different query parameters across the different pages of the site. Rather than maintain a 200+ item list (which may change), I decided to use search and replace filters to change the recorded URIs. I initially tried to filter “\?.*” to “”, but GA will not accept an empty replace field (nor will it accept whitespace). To get around that I went to filters which looked like “aspx\?.*” filtered to “aspx”. That seems to work ok, but it requires multiple filters for different extensions. It doesn’t seem like a particularly elegant way to go about it, but I haven’t found any other ideas. It would be a simple fix in the javascript, but that would prevent any additional profiles from recording parameters which may be of interest. Any thoughts?

    4. says

      Hey Mike,

      Good troubleshooting. Exactly the steps that I would follow. I would use an advanced filter that strips off all query string parameters. Remember, you can capture parts of the URL and then rewrite those parts out to a field. Try this reg ex:


      Then put $A1 in the constructor.

      You could tweak the JS and pass it an explicit value that does not include the query string parameters. I know all the data is available in the DOM, so you can use all JS, you don’t need to worry about using but would have to look it up.

      Try the advanced filter.


    5. Jon Beals says

      This is a great post. Is there a way to batch ignore query string data? We have many campaigns tracked and they all start with the same string of characters “?code=”. If I enter that into the ignore field will it ignore all those that start with that string?

      Thanks again for the post.

    6. says

      Hey Jon,

      This setting, is in fact, a batch field. If you enter ‘code’ into the field then it will strip all instances of the query string parameter regardless of the value.

      Hope that helps and thanks for the question!


      • says


        In that case you can either leave the data or you would need to use an advanced filter to remove the 23 from the URL. The advanced filter would need to capture different parts of the URI and override the Request URI field. Here are the basic settings:

        Field A: Request URI
        Pattern A: (^/products/)
        Constructor: Request URI
        Output Patter: $A1

        Make sure to test the above filter! Without know the exact format of your URLs it may not be right. But that should get you moving in the right direction.

        Thanks for the question,


    7. says

      Hi Justin, thanks for your reply. I constructed an advanced filter in a different way using RegEx, and I think it will work fine.



      (The Google Conversion University is excellent, too — I didn’t understand RegEx before their video!)

      – Johnny

      • says

        @Platini: You’re correct, you need to use utm_ campaign tracking parameters. You don’t need them all, you can just use utm_source. But why not use all of them for great data, then shorten the link with or some other shortener?

    8. says

      Hi Justin,

      Thanks for writing this post. Could you clarify the following about the “Exclude URL Query Param”:

      1) Are the values entered into the field case-sensitive?

      For example, “ocId” would be excluded but, “ocid” would not in the above URL

      2) Can regular expressions be entered into the field?

      For example, ocId1, ocId2, ocId3, ocId4, ocId5 could be simplified to “ocId\d”

      • says


        1. I would suggest you use a lowercase filter to normalize the all of your URIs to lowercase. That will make your data more consistent. Then the case does not matter :)

        2. No, you can not use a regular expression. You need to use a comma-separated list of all the parameters.

        Hope that helps, Justin

        • says

          Hi Justin,

          Q1. Great advice!
          Q2. That’s a shame. One for the feature request pile perhaps:)

          Further investigation seems to indicate like the new GA version also has a character limit for the delimited string. Is this number documented anywhere?

          And finally, when updating exclude query settings filters, how long after the changes are made will the rules be applied to the profile in terms of ‘real time’ and standard reports?

          *Apologies for the Spanish Inquisition but, I’m trying to troubleshoot an issue and so your advice is much appreciated.


    1. Bitacle Blog Search Archive – Google Analytics Configuration Mistake #2: Query String Variables

      […] In my previous post I discussed how an incorrect Default Page setting can cause a single page on. […]

    2. […] First, you can not use GA to collect any personally identifiable information (PII). This means no names, email addresses, IP addresses, etc. One mistake that many people make, inadvertently, is collecting PII in the URL. If you have a form that collects visitor data, and that form passes data via query string parameter, then you may be collecting PII. If you’re unsure if you are collecting PII, just check the top content report. Look for any records that include an email address, name, etc. It’s easy to resolve this issue, just exclude the appropriate query string parameters in the profile settings. […]

    3. […] Som det står, må du ikke benytte Google Analytics eller tredje part software til at indsamle personlige oplysninger om dine brugere. Det kan blandt andet ske ved at dit site generer URL’er med emailadresse eller navn i. URL’erne vil blive samlet ind i dine rapporter som resten af dine URL’er og det kan altså godt skride imod den privatlivspolitik, du skal følge. Er det tilfældet kan du følge denne vejledning til hvordan du ekskluderer disse URL i Google Analytics. […]

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>