Calculated fields

Looker Studio calculated field – Extract query parameter value from URL

The Looker Studio (ex Google Data Studio) calculated field below extracts the value of a specific query parameter and returns it as a text / string.

My query parameter value
REGEXP_EXTRACT(My url field,"^(?:.*)(?:\\?|&)my_query_param_key=([^&]+)(?:.*)$")

  • Input
    • Field corresponding to the URL / Page address with parameters (test / string)
      • Example 1 – Full URL:
      • Example 2 – Path & parameters: /folder/page.html?param1=value1&wishedparam2=wishedvalue&param3=value3
    • URL parameter key / name (string) of the wished value
      • Examples: my_param_key, wishedparam2
  • Output
    • Value of the specific URL parameter
    • Type: text / string
  • Calculated field formula
    • REGEXP_EXTRACT(My url field,”^(?:.*)(?:\\?|&)my_query_param_key=([^&]+)(?:.*)$”)

  • Example
    • Get the parameter value “site_search_kw” from Google Analytics page dimension: