Products
Insights

Query Parameter Blocklist

The query parameter blocklist allows you to prevent sensitive URL parameters from being captured in analytics data. This is useful for excluding tokens, passwords, or other private information that may appear in URLs.

Configuration

Add the data-insights-blocklist attribute to your script tag with comma-separated patterns:

<script
  src="https://cdn.example.com/insights.js"
  data-insights-channel="web"
  data-insights-subsite="en"
  data-insights-storefront="uk"
  data-insights-blocklist="token,secret,password">
</script>

Pattern Syntax

Blocklist patterns support both literal strings and regular expressions:

PatternMatchesExample URLs
tokenExact match?token=abc
token.*Starts with “token”?token=abc, ?tokenId=123
^secret$Exact match (explicit)?secret=xyz
pass\w+”pass” followed by word chars?password=abc, ?passkey=123

All matching is case-insensitive, so token will match Token, TOKEN, and token.

How It Works

When a page view is captured, the library:

  1. Parses all query parameters from the current URL
  2. Checks each parameter name against the blocklist patterns (values are not checked)
  3. Excludes any matching parameters from the analytics payload

Note: The blocklist matches against parameter names only, not their values. A pattern like token will block any parameter named “token” regardless of its value, but will not block a parameter like ?type=token.

Example: Given the URL ?user=john&token=secret123&page=1 with blocklist token:

{
  "page": {
    "query_params": {
      "user": ["john"],
      "page": ["1"]
    }
  }
}

The token parameter is excluded from the captured data.

Multiple Patterns

Separate multiple patterns with commas. Whitespace around patterns is automatically trimmed:

<script
  data-insights-blocklist="token, secret, password, auth.*, session.*">
</script>

Security Features

The blocklist includes built-in protections:

ReDoS Protection

Dangerous regex patterns that could cause performance issues are automatically detected and rejected. These patterns fall back to literal string matching:

  • Nested quantifiers: (a+)+
  • Overlapping alternations: (a|a)+
  • Repeated wildcards: .*.*

Invalid Pattern Handling

If a pattern contains invalid regex syntax, it gracefully falls back to a literal string comparison rather than throwing an error.

Programmatic Configuration

When using the JavaScript API, pass the blocklist as an array:

window.insights.init({
  channel: 'web',
  subsite: 'en',
  storefront: 'uk',
  queryParamBlocklist: ['token', 'secret', 'password']
});

Common Use Cases

Use CaseRecommended Patterns
Authentication tokenstoken, auth, jwt, bearer
Session identifierssession.*, sid
Password reset flowspassword, reset_token
OAuth flowscode, state, oauth.*
Tracking parametersutm_*, fbclid, gclid

Note: The blocklist only affects query parameters captured in page view data. It does not modify the actual URL or affect other tracking features.

Next Steps