Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Add Google Analytics Custom Segment

Hi, 

 

I am trying to get some Google Analytics data into PowerBI, however I need to filter it for a specific segment. I was searching the web for an answer, but could not find anything relevant. 

 

In essence, I need to filter everything for this: sessions::condition::ga:orderCode==XX11XX2X [or gaid:xxxxxxxxxxxxxxxxx] (taken from G.A. query explorer)

 

Query below if it helps:

 

let Multiple =(id1 as text,id2 as text,id3 as text)=>
let
Source = GoogleAnalytics.Accounts(),
#"11111111" = Source{[Id=id1]}[Data],
#"XX-11111111-1" = #"11111111"{[Id=id2]}[Data],
#"11111111" = #"XX-11111111-1"{[Id=id3]}[Data],
#"Added Items" = Cube.Transform(#"11111111",
{
{Cube.AddAndExpandDimensionColumn, "ga:yearMonth", {"ga:yearMonth"}, {"yyyymm"}},
{Cube.AddMeasureColumn, "Sessions", "ga:sessions"},
{Cube.AddMeasureColumn, "Bounces", "ga:bounces"},
{Cube.AddMeasureColumn, "Transactions", "ga:transactions"},
{Cube.AddMeasureColumn, "BounceRate", "ga:bounceRate"}
}),
#"Filtered Rows" = Table.SelectRows(#"Added Items", each [yyyymm] >= 201701)

in
#"Added Items"
in Multiple

 

Any help will be appreciated.

 

Thx ! 

1 Reply

  • v-yuta-msft's avatar
    v-yuta-msft
    Community Support

    Hi sailor321,

     

    Both GA connector and Web.Contents() don't support custom segment in power query currently because post request in Web.Contents() function doesn't support OAuth2. In addtion, it's still a requested feature, please refer to this idea. As a workaround, you may use python or R script to achieve the filtered data from GA and then import the data into power bi.

     

    Regards,

    Jimmy Tao