Google Data Studio

Google Data Studio secondary dimension like inside Google Analytics

One of the most accessible and easy feature to begin to explore data inside Google Analytics is the secondary dimension selector. It is available directly through table standard reports and allows to break down metrics with a flat combination of 2 dimensions, instead of one by default.

Of course, it is just a first step of data exploration. But because it is very intuitive and strongly anchored in Google Analytics usages, it is interesting to propose it inside Google Data Studio.


Google Data Studio secondary dimension selector as inside Google Analytics

In my opinion, we can consider secondary dimension selector as a feature incentive to users for data exploration. Users begin to cross 2 dimensions trying to gain insight on the first level of data provided by standard reports. Then, they understand that it is nice for a first breakdown but they should quickly switch on another solution (custom reports, exports, additional custom data visualisation, data studio explorer…) to break down their data through more dimensions, and so, find correlations and trend factors.

Let’s apply these principles on Google Data Studio, providing this feature inside our dashboards to allow readers to get a first light complementary information inside their table charts, improving the smoothness of data navigation for their understand and potentiel further detailed investigation (deeper exploration through other methods & tools).

Of course, this feature is not limited to Google Analytics fields and can be applied to other data sources.

We cann also apply it as a simple dimension switcher. So, a kind of primary dimension selector, useable inside more chart types.


The result

Let’s see this custom feature in action, using acquisition dimensions from Google Analytics. You will remark that there are some constraints like the constant presence of the column for the second dimension inside the table chart, but the mechanism fundamentally makes the job.



Ingredients to create the mechanism of secondary dimension selector

To get this secondary dimension selector, we will use the following native features provided by Google Data Studio:

  • Data source parameter
    This amazing feature was recently released. It is very promising and offers already a lot possibilities (including hacks as I like…miam..😉). We will use it to store our proposal of secondary dimensions
  • Calculated fields
    To wrap the parameter as a calculated field and to map the selected option of the parameter with the related dimension to display (meta data to data)
  • Drop-down list control
    To list and select the wished secondary dimension
  • Table chart
    Finally, to display our data

Data source parameter

Let’s create a parameter inside our Google Analytics data source to store the options we wish to propose to the report reader as secondary dimensions, so their respective names.

Contrary to secondary dimension selector inside Google Analytics, we will not propose all available dimensions but focus on the purpose of the table chart. In our example, the important acquisition dimensions.

We need to be careful about 2 points when we create the parameter:

  • The name of the parameter should be correctly chosen to reflect all usages of the parameter inside all the report(s): For the moment we cannot overwrite it inside each control widget.
  • Fill the options of the parameter respecting the wished sorting inside the control widgets. As the name of the parameter, the sorting cannot be changed on control widgets using this parameter

In the example below, we will create “Acq dimension selector” parameter as a list of text values:

  • Channel (Google Analytics Default Channel Grouping)
  • Medium
  • Source
  • Source / Medium
  • Campaign
  • Landing page
  • Ad content
  • “-” for default selection


Calculated fields

Now, we need 2 calculated fields:

  • The first one is just a workaround to permit to create the second: For the moment CASE statements are not compatible with parameters even if they are recognized by the formula editor. So we will just create a calculated field, as example “Acq dims selector wrp” and just reference our freshly created parameter “Acq dimension selector” as formula (displayed with a purple background in the editor, the color of the parameters).
  • Then, we create an another calculated field “Acq secondary selected dimension” with CASE statement to map each possible value of the parameter to the right dimension of the data source.

CASE
WHEN Acq dims selector wrp = "Channel (GA DCG)" THEN Default Channel Grouping
WHEN Acq dims selector wrp = "Medium" THEN Medium
WHEN Acq dims selector wrp = "Source" THEN Source
WHEN Acq dims selector wrp = "Source / Medium" THEN Source / Medium
WHEN Acq dims selector wrp = "Campaign" THEN Campaign
WHEN Acq dims selector wrp = "Landing page" THEN Landing Page
WHEN Acq dims selector wrp = "Ad content" THEN Ad Content
ELSE "-"
END


Drop-down list control

Now the configuration of the data source is finished, let’s add the secondary dimension selector:

Add the drop-down list control in your page and select the parameter “Acq dimension selector” as control field (Data tab), disabling search box and adapt styles.



Table chart

Our last action is the creation of the table chart with:

  • Primary dimension (here, default channel grouping from GA)
  • Dynamic secondary dimension through “Acq secondary selected dimension
  • Wished related metrics
  • Adapted configuration (rows, filters, segments, control activation…) and styles

Then, we test the final result and the interaction between the dropdown menu and displayed data in the table.



Primary dimension selector

Of course, we can use the same mechanism to switch from a dimension to another for the primary dimension, so for most of the charts (and also for a lot of other cases like drill down).

Here an example on a bar chart with top products sales, switching from products attributes to other through GA enhanced ecommerce dimensions (name, category, brand, variant for size…).

For this example, I’ve also added a dynamic consistent title concatenating the parameter selection with the static description of the chart.



Final thoughts

One year ago, I wished to find a solution inside Google Data Studio to build a system of secondary dimension selector like everybody loves inside Google Analytics. My first shot was based on data blending and Google Sheets for dimensions list. But for the moment, CASE statement gets some problem when you try to create it as chart calculated dimension using a blended data source. So I’ve created this issue waiting for its resolution to finish my article.

Since last week, through Parameters, Google Data Studio team has developed an amazing solution for this kind of use cases (and many more others). I was really happy when I understand that a huge workaround is no more necessary for my need because the right and consistent feature is now available. And I’m sure that the little bugs and limitations discovered through this article will solved in the next weeks.

At last, since my back from holidays, I like discovering how the creativity of GDS community is going ahead about GDS parameters. Here a thread on Twitter from Ralph Spandl summing up how power users (Mimoune, Michael, Lee, Pablo, Thomas, Iñaki…) jump into this feature playground for the good of data viz inside Google Data Studio.
It is a real positive signal of the importance of this new Data Studio addition and I’m sure that other blog posts will be published about the subject, close or not. Here we used it for dimension switching but other capabilities combined with BigQuery or community custom viz are even more crucial.


C’est dans les vieux pots…mais pas que…