Data Studio
3.4K members online now
3.4K members online now
Ask questions about Data Studio
Guide Me
star_border
Reply

Counting Pageviews Conditionally

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi,

 

I have a custom dimension called 'PageType'. PageType can have 3 values, say 'A', 'B' and 'C'. Each of these values represents a different page on my site.

 

I want to create a custom metric called 'A Count' that gives me a count of Pageviews when 'PageType' = 'A'. I'd create a custom variable for each PageType which would then allow me to calculate against these custom variables.

 

Thanks for any assistance.

Counting Pageviews Conditionally

Follower ✭ ✭ ✭
# 2
Follower ✭ ✭ ✭

I have not tried the solution, but I remember seeing a similar question before I think the solution is something like SUM(CASE WHEN PageType= 'A' THEN 1 ELSE 0 END) 

Counting Pageviews Conditionally

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Thank you Chun.

 

I've tried that. When I put that metric into a report with PageType, I just get a count of '1' where PageType = 'A'. Also, how do I ensure I'm counting Pageviews instead of say, Sessions?

 

 

Counting Pageviews Conditionally

Follower ✭ ✭ ✭
# 4
Follower ✭ ✭ ✭

Maybe you can paste the formula used as the formula here to see if there is any thing you missed.

 

As far as I can think of, it the formula used is SUM(CASE WHEN PageType= 'A' THEN 1 ELSE 0 END)  the sum return should always be equal to the total no. of rows with PageType = 'A'.

 

As for your 2nd question, don't really get what your question is as Pageview and Session is 2 different count variable in GA, if you are counting Pageview in your formula, you would never be counting session. Did I missed something?

 

Counting Pageviews Conditionally

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭

Hi,

 

Here's a thread that describes what I'm looking for

https://www.en.advertisercommunity.com/t5/Data-Studio/Calculated-Field-Percent-of-Total/td-p/719766

No solution offered there unfortunately.

Counting Pageviews Conditionally

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭

I am running to similar problem, any fixes?

Counting Pageviews Conditionally

Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭

Did anyone succeed by trying "metric * MAX(CASE WHEN condition THEN 1 ELSE 0 END)" as described here: https://support.google.com/datastudio/answer/7359285?hl=en&ref_topic=7570421