We are trying to track all of the page views to certain sites. We ONLY need to know how many folks visit each page. Unfortunately what is happening is Google Analytics (GA) is not aggregating the page views. Rather than aggregating all of the page views whose page is identical GA treats them all separately. Additionally, we are seeing all kinds of PII which we do not want to do.

We would like to see all of the data aggregated to just the page. Like this:


Instead, we are also seeing page views for the below page as well as:


  1. Does anyone have any idea how to do this?

  2. Is there a way I can use a REGEX to remove every query or do I have to list all of the queries separately?

  3. How would I implement this in Google Tag Manager (GTM)?

  4. Is there any 3rd party software compatible with GTM and or GA available to accomplish this?

3 Answers 3


POST instead of GET?

Well, if you could use a POST instead of a GET with query string, that would certainly be best.

301 to remove query strings

One solution, would be to do a 301. So the user arrives with the GET and query strings, you save that data, on your server and do a 301 to the page without the query string. In effect you will get two hits, one without the query strings. If you need the data displayed in the page, though, it requires a cookie.


Another solution is to have an IFRAME inside your page. All users see the same IFRAME when they hit that page with the query string. The counter on that IFRAME page reflects the number of users who accessed that page whatever the query strings.

In the old days people would also use a 1x1 transparent GIF image. However, Google Analytics does not track such. You would need to have something on your server to count the number of time this image gets served. An interesting side effect, though, is to make sure the image gets cached so you can count unique accesses that way (it's not 100% bullet proof, but really no method I know of will give you 100% accuracy of hits on the Internet.)

One problem with the image, you want to place it under a folder that is blocked in robots.txt so at least compliant robots do not generate false hits.

Google Analytics URL ParametersGoogle Analytics Filters

As pointed out in a comment by gintsg, the Google Search URL Parameter is for SERP, not GA. So this won't help. Instead, you want to use GA Filters.

The simplest, but possibly not the best, is to tell GA about your query strings. More precisely, to tell it to ignore those fields when they appear on your URL.

Screenshot of Google Search URL Parameter setup page

  1. Click on your property
  2. Click on Crawl
  3. Click on URL Parameters
  4. Click on whatever OK button (they generally ask you whether you really want to do that)
  5. Click on Add parameter
  6. Enter the name of your parameter (i.e. "phone")
  7. Make sure to select "ignore" (No: does not affect page content (ex: tracks usage))
  8. Save

Although you may present the page with content such as the phone number, it will do what you expect in terms of counting user accesses.

  • Your "GoogleAnalytics URL Parameters" section is wrong in this case. These parameters will be filtered only in Google SERPs. It's not for GA.
    – gintsg
    May 31, 2018 at 2:43
  • @gintsg, good point! You need to use the filters. May 31, 2018 at 4:42
  • 1
    Yes, the filters in GA will work or the solution in your mentioned link under "Remove Queries with Google Tag Manager" is my favourite, what I have used a couple of times and works very well. Of course, to use POST rather than GET method is the best out of all solutions, especially if the issue is related to PII data. So changing GET to POST in this case must be primary and all other solutions should be as temporary till dev team change GET to POST. Cheers
    – gintsg
    May 31, 2018 at 4:49

Make a new view in Google Analytics that filters out the parameter string. Keep a view that does not have this filter, as you never know when you might want that data.

The filter to do this is

Filter Type - Custom

Search and Replace

Filter Field

Request URI

Search String


Leave the Replace String field blank

  • 1
    In this case, he has PII data which can't be saved in Google Analytics databases in any situation. These parameters must be removed in every single view, otherwise, Google will delete a huge bunch of data when they will realise, that PII data is in the database.
    – gintsg
    May 31, 2018 at 20:27

First of all, need to understand that personally identifiable information (PII) data leaking is a serious issue and you should consider changing your data sending/receiving method in your website from GET to POST. This must be your primary goal if the parameters are related to PII.

In Google Analytics you must remove these parameter in every single view:

Analytics customers are prohibited from sending personal information to Google. The Analytics terms of service, which all Analytics customers must adhere to, prohibits sending personally identifiable information (PII) to Analytics (such as names, social security numbers, email addresses, or any similar data), or data that permanently identifies a particular device (such as a mobile phone’s unique device identifier if such an identifier cannot be reset). Learn more about how to avoid sending PII. Your Analytics account could be terminated and your data destroyed if you use any of this information.

In your case, phone; busname; addr; city; state; postal are all PII by Google interpretation.

Other issues if you are leaking PII in your URL parameters: You could be against Terms & Conditions with other services as well, not only Google Analytics. If you are using AdSense, Facebook Remarketing and any other services, you could send these URL to these servers which could cause problems and your accounts could be terminated.

If changing GET to POST not possible: You should encrypt all of your PII data.

You can send Google Analytics an encrypted identifier or custom dimension that is based on PII, as long as you use the proper encryption level. Google has a minimum hashing requirement of SHA256 and strongly recommends the use of a salt, with a minimum of 8 characters. Notwithstanding any of the foregoing, you may not send Google Analytics encrypted Protected Health Information (as defined under HIPAA), even if it is hashed or salted.

How you can remove these data from Google Analytics:

1. In Google Analytics view settings

This is the easiest and simplest way to do it. Just go to your view settings under Admin > View Settings and add you parameters which you want to exclude in Exclude URL Query Parameters field. You must do it for every single view. enter image description here

2. In Google Taga Manager

For this method make sure that you have enabled Page URL variable. Next, create a new custom variable and choose Custom JavaScript with this script where under var params you include your parameters which you want to exclude. Name the variable Remove Parameters from URL or as you wish.

function() {

  var params = ['orgid', 'phone', 'busname', 'addr', 'city', 'state', 'postal', 'categories'];
  var _page = {{Page URL}};
  var a = document.createElement('a');
  a.href = _page;

  if (a.search) {

    var qps = a.search.replace('?', '&');
    var i;

    for (i = 0; i < params.length; i++) {

      var _param = params[i];
      var regex = new RegExp('&' + _param + '=[^&]*(&|$)', 'gi');
      qps = qps.replace(regex, '&')

    qps[0] === '&' ? qps = qps.slice(1) : '';
    a.search = qps;


  return a.href;


Next, go to your Google Analytics settings variable or to every single Universal Analytics tags and update settings to follow: enter image description here

For Facebook Pixel and other 3rd party remarketing or other tags

Please, exclude firing the tags in GTM on URLs which contains these parameters to avoid any Terms & Condition problems.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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