cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jlie Regular Visitor
Regular Visitor

Calculate One-Time Visitors from Google Analytics Session Data

I have a data table that contains single Sessions and the Dimension ga:userType, that states if the Session is the first session of the identified user or a subsequent one ("New Visitor" vs. "Returning Visitor"). The ga:clientId dimension tells me the actual user, how ga identifies them.

 

I am now trying to create a measure, that calculates the number of one-time visitors vs. the number of returning visitors: It should therefore aggregate the distinct Client Ids for all the Users that only have a "New Visitor" session and no subsequent "Returning Visitor" Sessions. 

 

How could I accomplish that? Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
jlie Regular Visitor
Regular Visitor

Re: Calculate One-Time Visitors from Google Analytics Session Data

Ok, i figuered it out:

 

I need two measures on the table AnonymousSessions

Returning Visitors = 
CALCULATE(
    DISTINCTCOUNT(AnonymousSessions[Client Id]);
    AnonymousSessions[User Type]="Returning Visitor"
)

OneTimeVisitors = 
    DISTINCTCOUNT(AnonymousSessions[Client Id]) - [Returning Visitors]

This yields the correct data; I can now slice/dice the sessions by channel or date and see 100% accurate the returning and one-time visitors in the respective context.

View solution in original post

4 REPLIES 4
Moderator v-yuezhe-msft
Moderator

Re: Calculate One-Time Visitors from Google Analytics Session Data

Hi @jlie,

Could you please share sample data of you table and post expected result here?

Assume that you have a data table as follows.
1.PNG

You can create two measures.
number of one-time visitors = CALCULATE(COUNTA('Session'[ClientID]),FILTER('Session','Session'[UserType]="New visitor"))
number of returning visitors = CALCULATE(COUNTA('Session'[ClientID]),FILTER('Session','Session'[UserType]="Returning visitor"))

2.PNG

Thanks,
Lydia Zhang

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
jlie Regular Visitor
Regular Visitor

Re: Calculate One-Time Visitors from Google Analytics Session Data

 

new-returning-visitors-per-session.PNG

 

Of course, yes. So this is the relevant structure of my table. Of course, in reality the ClientIds are the GA Client Ids and the SessionID is calculated from Client-Id and the Session-Iterator. User Type is nothing more than a if [session count] = 1 then "new" else "returning"; wether I import it as a dimension from Google Analytics or calculate it myself.

 

My expected Result:

The "One Time Visitors" Measure counts Clients C and D, and therefore gives me a 2.

A "Recurring Visitors" Measure counts Clients A and B, and therefore also gives me the number 2.

 

I think I need some nested Calculations, because the formula needs to evaluate for every single Client-Id, if it is "New Visitor", if there are subsequent Sessions with "Returning Visitor" and only then make a DISTINCCOUNT on the [Client Id] Column.

jlie Regular Visitor
Regular Visitor

Re: Calculate One-Time Visitors from Google Analytics Session Data

Ok, i figuered it out:

 

I need two measures on the table AnonymousSessions

Returning Visitors = 
CALCULATE(
    DISTINCTCOUNT(AnonymousSessions[Client Id]);
    AnonymousSessions[User Type]="Returning Visitor"
)

OneTimeVisitors = 
    DISTINCTCOUNT(AnonymousSessions[Client Id]) - [Returning Visitors]

This yields the correct data; I can now slice/dice the sessions by channel or date and see 100% accurate the returning and one-time visitors in the respective context.

View solution in original post

Andrian Occasional Visitor
Occasional Visitor

Re: Calculate One-Time Visitors from Google Analytics Session Data

Hello,

I am using powerBI Desktop and using the GA connector provided by PBI. How do you get the client ID and the Session Id? I don't see them in the data. Thank you.

Fred

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 506 members 3,782 guests
Please welcome our newest community members: