Skip to content

Variable Template (Server) for Google Tag Manager that Excludes or Whitelist Query String Parameters. Parameters can be either Removed or the parameter value can be Redacted.

License

Notifications You must be signed in to change notification settings

gtm-templates-knowit-experience/sgtm-exclude-whitelist-query-strings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Exclude or Whitelist Query String Parameters - SGTM Variable

The probably most common cause for Personally Identifiable Information (PII) leaking into analytics tools is through the URL of the website. This Variable Template for Google Tag Manager Server-Side (SGTM) fixes this problem by making it possible to Exclude or Whitelist Query String Parameters from the URL.

Images of the Template is at the bottom.

This Template is available in the Google Tag Manager Template Gallery.

Variable Settings

Page URL

As standard page_location is chosen, but you can use any Variable containing a valid URL as input.

Output Result

Setting Example Output
Page URL with Parameters https:https://domain.com/path?query=something
Page URL without Parameters https:https://domain.com/path
Page Path with Parameters /path?query=something
Parameters with Question Mark ?query=something
Parameters without Question Mark query=something

Lowercase Parameters

Parameter matching is by default Case Sensitive. By ticking this box, all incoming parameters will be set to lowercase, making it easier to match parameters.

Redact Email Adresses

Redact possible email adresses independent of the Parameter matching. Also Whitelisted parameters will be checked and redacted if an email is found.

If an email is found, the email adress will be replaced with [EMAIL REDACTED].

Example: https:https://domain.com/?query=[EMAIL REDACTED]

Whitelist or Exclude Query Parameters

You can either Whitelist or Exclude Parameters.

Whitelist means only parameters listed are allowed to pass through. This is the safest option for not allowing PII parameters leaking into your analytics and marketing tools. If you choose this option, it's important that you add all parameters that you need. That can be campaign tracking parameters and internal search parameters.

Exclude can also be used as a method for blocking PII parameters. It's less "safe" than using Whitelist, but are added as an option. With this method, add parameters you don't want to be passed through to your analytics tool.

Remove or Redact Parameter Value

If you choose Remove, you remove the parameter and the parameter value. Choosing Redact means that the parameter will be kept, but the value will be redacted. Example: query=[REDACTED].

Add Query Parameters for Whitelisting/Exclusion

You can add parameters using a table or a text field. Add the parameters to the table/texxt field that you want to Whitelist/Exclude.

Example Setups

Example Setup for Google Analytics 4 (GA4)

In the GA4 example setup below, 1 extra GA4 parameter has been created (page_query_string). Settings below:

  1. page_location with Page URL Parameters Whitelisted and other Parameters Removed.
  2. Query String without Question Mark, Whitelisted and other Parameters Redacted is sent to parameter page_query_string.

We overwrite page_location with the new URL where Parameters are Whitelisted and other Parameters removed. To page_query_string we send the Query String with the Whitelisted Parameters other Parameters as Redacted.

Google Analytics 4 (GA4) example setup

Example Output

Settings Allowed parameters page_location input page_location output
Page URL with Parameters (removed) query https:https://domain.com/path?query=something&secondparam=something-else https:https://domain.com/path?query=something
Parameters without Question Mark (redacted) query https:https://domain.com/path?query=something&secondparam=something-else query=something&secondparam=[REDACTED]

Example Setup for Universal Analytics

In the Universal Analytics example setup below, 3 different variables have been created:

  1. Page URL with Parameters Whitelisted and Removed
  2. Query String without Question Mark, Whitelisted and Redacted
  3. Referral with Parameters Whitelisted and Removed

We overwrite page_location with the new URL where parameters are Whitelisted and other Parameters removed. To Custom Dimension 1 (cd1) we send the Query String with the Whitelisted Parameters and other Parameters as Redacted. We overwrite page_referral with the new Referral where parameters are Whitelisted and other Parameters removed.

Using this setup we get "clean" URLs and referrals, while we at the same time can investigate what other parameters are in use.

Universal Analytics example setup

Images of the Variable Template

Variable Template (Server) for Google Tag Manager that Exclude or Whitelist Query String Parameters.

Exclude and Remove Query Parameters

Whitelist (include) Query Parameters

About

Variable Template (Server) for Google Tag Manager that Excludes or Whitelist Query String Parameters. Parameters can be either Removed or the parameter value can be Redacted.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages