Looker Studio calculated field – Extract query parameter value from URL
January 23, 2022
- by Mehdi Oudjida
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.
- Input
- Field corresponding to the URL / Page address with parameters (test / string)
- Example 1 – Full URL: https://www.site.com/folder/page.html?param1=value1&wishedparam2=wishedvalue¶m3=value3
- Example 2 – Path & parameters: /folder/page.html?param1=value1&wishedparam2=wishedvalue¶m3=value3
- URL parameter key / name (string) of the wished value
- Examples: my_param_key, wishedparam2
- Field corresponding to the URL / Page address with parameters (test / string)
- Output
- Value of the specific URL parameter
- Type: text / string
- Used function(s)
- Example
- Get the parameter value “site_search_kw” from Google Analytics page dimension:
REGEXP_EXTRACT(Page,”^(?:.*)(?:\\?|&)site_search_kw=([^&]+)(?:.*)$”)
- Get the parameter value “site_search_kw” from Google Analytics page dimension:
My query parameter value
REGEXP_EXTRACT(My url field,"^(?:.*)(?:\\?|&)my_query_param_key=([^&]+)(?:.*)$")