• Home
  • Google Analytics
    • Customizations
    • For Ecommerce
  • Speaking
  • About
    • About Me
    • Contact Me
    • Disclaimer and Privacy Policy

Analytics Talk

Digital Analytics for Business

You are here: Home / Common Problems / Google Analytics Configuration Mistake #2: Query String Variables

Google Analytics Configuration Mistake #2: Query String Variables

Posted: September 21, 2006 25 Comments

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:

http://www.mysite.com/dir/index.php?sess=1234&ocId=3&var1=foo&var2=bar

Results in this page view:

/dir/index.php?sess=1234&ocId=3&var1=foo&var2=bar

And this URL:

http://www.mysite.com/dir/index.php?sess=4567&ocId=6&var1=bar&var2=foo

Results in this page view:

/dir/index.php?sess=4567&ocId=6&var1=bar&var2=foo

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.

query_string.gif

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

sess,ocId,var1,var2

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.

Filed Under: Common Problems, Tracking Tagged With: google-analytics, Tips

Comments

  1. Robert Friedman says

    January 22, 2008 at 12:51 pm

    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!

    Cheers,
    Robert

    Reply
  2. Justin Cutroni says

    January 24, 2008 at 11:09 am

    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,

    Justin

    Reply
  3. Mike says

    October 14, 2008 at 5:57 pm

    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?

    Reply
  4. Justin Cutroni says

    October 29, 2008 at 7:01 am

    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.

    Justin

    Reply
  5. Jon Beals says

    March 6, 2009 at 4:06 pm

    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.

    Reply
  6. Justin Cutroni says

    March 12, 2009 at 8:21 am

    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!

    Justin

    Reply
  7. Johnny W says

    April 30, 2009 at 5:51 am

    I’m currently struggling and I hope someone can help me. What if your site uses “SEO Friendly” (aka “Static”) URIs?

    For example, instead of:
    http://www.domain.com/products.aspx?page=23

    We use:
    http://www.domain.com/products/23

    I don’t want to see the page number (23) so how would I strip that out?

    Thanks for any help!

    Reply
    • Justin Cutroni says

      April 30, 2009 at 8:21 am

      Johnny,

      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,

      Justin

      Reply
  8. Johnny W says

    April 30, 2009 at 9:46 am

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

    (.*products)/(\d.*)$

    Thanks!

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

    – Johnny

    Reply
  9. Tony says

    June 10, 2009 at 4:46 am

    Interesting post, keep the good stuff coming, good content appreciated!

    Reply
  10. Jonah Keegan says

    April 8, 2011 at 1:29 pm

    Thank you so much for including the bit at the end about edits only applying to future data! Exactly the question I was trying to answer. :D

    Reply
  11. Platini says

    July 12, 2012 at 6:27 pm

    I would like to be able to track the referrer.
    For example:
    http://www.example.com/examplepage.htm?ref=fb is a link I posted on facebook
    http://www.example.com/examplepage.htm?ref=nl is a link from a newsletter I sent out.

    I would like to be able to track where my visitors are coming from.

    What would be the best strategy in such a scenario?

    Reply
  12. Platini says

    July 13, 2012 at 7:06 pm

    PS: Regarding my post above, I know I could use UTM tags, for xample:

    http://www.example.com/examplepage.htm?utm_source=nl&utm_medium=e&utm_campaign=v%20

    However, due to the non-commercial nature of my pages I would like to
    a) keep the links short and
    b) avoid the word “campaign”.

    Reply
  13. Platini says

    July 13, 2012 at 8:01 pm

    PPS: After more searching I found “Master Tracking Codes” and UTM_id, but it is not longer supported:

    http://support.google.com/urchin45/bin/answer.py?hl=en&answer=2633697&topic=2633609&ctx=topic

    Is there any way to do it with Google Analytics?

    Reply
    • Justin Cutroni says

      July 20, 2012 at 2:16 pm

      @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 bit.ly or some other shortener?

      Reply
  14. Alex says

    February 15, 2013 at 7:35 am

    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”

    Reply
    • Justin Cutroni says

      February 19, 2013 at 9:54 am

      @Alex:

      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

      Reply
      • Alex says

        February 19, 2013 at 10:10 am

        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.

        Reply

Trackbacks

  1. bitacle.org says:
    September 22, 2006 at 7:50 am

    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. […]

    Reply
  2. this just in » Google Analytics: How to Tell When Something is Wrong says:
    October 12, 2006 at 10:21 pm

    […] If you see ‘(other)’ in your reports check your profile configuration. You’re probably filling your database with bad data. You may need to exclude some query string parameters. Read Google Analytics Configuration Mistake #2: Query String Variables or the official Google Analytics help docs. […]

    Reply
  3. Analytics Talk » Top 5 Google Analytics Resolutions for 2007 says:
    January 3, 2007 at 1:16 pm

    […] Google Analytics Configuration Mistake #1: Missing Default Page Google Analytics Configuration Mistake #2: Query String Variables Google Analytics Configuration Mistake #3: Third Party Domains […]

    Reply
  4. Analytics Talk » Understanding The Google Analytics Terms of Service says:
    June 26, 2007 at 9:30 am

    […] 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. […]

    Reply
  5. Har du læst vilkårene i Google Analytics? -- Online marketing og webstatistik says:
    July 19, 2008 at 2:24 am

    […] 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. […]

    Reply
  6. URLs in Google Analytics, Page Tagging Update, and Wow, its hot | Intersections says:
    July 27, 2009 at 11:42 pm

    […] for simple solutions, but if you have more complex needs, see this post by Justin Cutroni. Or if you need web analytics inspiration in general, read Avinash Kaushik’s latest […]

    Reply
  7. Tips for structuring your Google Analytics account | Seperia says:
    June 6, 2013 at 7:10 am

    […] Main reporting profile – includes all of your data, clean of internal traffic and extraneous parameters. […]

    Reply

Leave a Reply Cancel reply

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

My Books

Google Analytics by Justin Cutroni
Learn More on Amazon.com

Performance Marketing co-authored by Justin Cutroni
Learn More on Amazon.com

Recent Posts

  • Understanding the Google Analytics Cohort Report
  • Using Offline and Online data to drive Google Analytics Remarketing
  • Understanding Cross Device Measurement and the User-ID
  • Universal Analytics: Now out of beta!
  • Advanced Content Tracking with Universal Analytics

Categories

  • About Google Analytics (25)
  • Analysis (52)
  • Analytics Strategy (3)
  • Campaign Tracking (14)
  • Ecommerce (8)
  • Event Tracking (10)
  • Remarketing (2)
  • Reporting (10)
  • Resources (7)
  • Tag Management (5)
  • Tips (25)
  • Tracking (52)
  • Uncategorized (64)
  • Universal Analytics (9)
  • Web Analytics (15)

Copyright © 2023 ·News Pro Theme · Genesis Framework by StudioPress · WordPress