I have a search page on a hotel property website that can have up to 12 parameters in the url. Note that sometimes it may have none of these parameters. The parameters are all for optional facilities that the hotel could provide. If the parameter is present it's value is always 'Yes'.

What I want to do is simply create a visual report such as a bar chart within Data Studio that shows a count of page views for each of these 12 parameters.

To do this I started making custom dimensions using the following REGEX. Each dimension looks for a specific url parameter. In this case 'offers'. To clarify, there are 3 possible scenarios here. A page may not have the url or it may have it with either 'Yes' or 'No' as a value.

REGEXP_MATCH(Page, '(?i)\boffers=yes\b' )

I know that this is definitely a valid REGEX expression that can detect the url parameter "offers=yes", and it can do this without case sensitivity.

The dimension using REGEX being created

However even creating a simple table with dimensions using the exact REGEX above and a third column using the 'Page' dimension never seems to show a 'true' result in my table.

Sample table testing for matching url parameters

Ultimately I want to visualise this into a bar graph that shows columns for the number of references to each url parameter I am tracking, irrelevant of the page the parameter was part of. Here is a mockup of this ideal end result...

Mockup of ideal desired results

  • share your data source
    – Evgeniy
    Feb 4, 2022 at 14:45

1 Answer 1


Constructing a Data Studio Report with Regex

  1. Create a report and click edit next to your data source
  2. Select "Add Field"

enter image description here

Creating Custom Regex Field

In Data Studio escaping is weird. You have to use \\/ instead of \/ to escape a /.

The following regex will match urls with a query string in your example:

REGEXP_MATCH(Landing Page, '.*/\\?swimmingpool=yes$' )

enter image description here

  1. Add your regex and then select Update > Done
  2. Next, create a chart and add dimensions with the field you just created

enter image description here

In my example, you can now see that /?x=yes returns true.

If you want to use a bar chart we can do that too by creating a Chart Field:

enter image description here

Next add your conditions:


and Viola!

enter image description here

These probably aren't exactly what you're looking for, but you can use these examples to create your own custom reports.

Edit: If you want to filter out anything that does not include your query parameters:

add filter to data studio report

Now select our "has query string" metric. This is an example of why creating custom dimensions and metrics is useful. See, we created both a dimension and metric for things with query strings. The metric, which is just a variable, that we named has query string we gave the value Has Query String = True. It's a boolean, meaning it's value is either True or False, 0 or 1. In our regex for the dimension we created we are matching urls that have our query string. We're using the metric to help us be more specific.

enter image description here

Now we have only the urls that match, nothing more.

enter image description here

  • Hi thanks for helping Mike. What I want is a graph with the 20 or so possible url parameters we have that are for optional extras in the hotels. So I need to manually define these in the regex I believe, otherwise we may get all sorts of things appearing. It may be that my regex shown in the question is fine. The main issue I have is that I'm just not sure how to construct the report I want to see. I simply want page views on the vertical by the unique url param on the horizontal.
    – AdamJones
    Jan 24, 2022 at 12:53
  • @AdamJones Hopefully you find this example helpful. Feb 1, 2022 at 18:30
  • Thanks for this @Mike Ciffone. I get stuck however adding the metric. Adding it with the "Has Query String = true" doesn't work as "has query String" isn't found as a metric. I have already created it as a "dimension" but not a metric. Can you clarify ?
    – AdamJones
    Feb 4, 2022 at 1:21
  • @AdamJones Not sure I understand what you mean. Refer to my screenshot, it must be in both places. Feb 7, 2022 at 19:26
  • Ok understood. One other question. You use the dimension 'Landing page'. In Data Studio, does that refer to the page a user first hits when accessing a site ? As I don't want that, I want the url irrelevant if it was the first thing they saw when landing on the site or not.
    – AdamJones
    Feb 8, 2022 at 1:04

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.