AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Data Studio
4.6K members online now
4.6K members online now
Ask questions about Data Studio
Guide Me

Google Data Studio Help with Filters in Custom Fields

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Alright, I'll admit I don't know the first thing about building a custom dimension/metric. I have been searching this forum as well as other websites for info on how to build a more complicated dimension/metric than one data set added/subtracted/divided/multiplied to another, but my google-fu skills have fallen short. Best I can come up with is below.


Here is the situation. I have ads on a site that are loaded through a very poorly implemented ad plugin that send an event to GA. The issue is that the ads trigger twice (once for mobile and once for desktop) on each page load, even tho only one ad shows (the desktop ad on a desktop, a mobile ad on mobile). I am working on fixing this, but in the interim I want to make a custom dimension that only shows desktop views and another dimension that only shows mobile views. Then I want to make another custom dimension (lets call it Actual Ad Views) that adds these together. The thought process here is that the desktop dimension will filter out the mobile views and vice-versa with the mobile dimension. Then the Actual Ad Views custom dimension will add together ONLY the ads that showed.


Great, so that's the plan, now how do we actually make this?!?!? I think I would start with a case argument (?) but don't know the language (?) that custom dimensions/metrics is built with to know if there is a better operator. But my thought process is something along the lines of


case if desktop then 1, else 0 END


which obviously doesn't work. My question is WHY, and also, how would/should I build this?

Re: Google Data Studio Help with Filters in Custom Fields

Visitor ✭ ✭ ✭
# 2
Visitor ✭ ✭ ✭
found this link as well support that is similar but different
and created this
SUM( CASE WHEN REGEXP_MATCH( Device Category , Mobile (Including Tablet) ) THEN 1 ELSE 0 END )
based on it...

...still didn't work...