Skip to content

Commit

Permalink
Create fnGoogleConnector.md
Browse files Browse the repository at this point in the history
  • Loading branch information
PBI-DataVizzle authored Aug 22, 2022
1 parent 070ca77 commit 09bd7c3
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions GoogleAnalytics/fnGoogleConnector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Google Analytics
### fnGoogleConnector
get data from Google analytics, (un)comment out variables

```C#
let
fnGetGAData = ( //fnGetGAData: see code to check dimensions/measures
AccountId as text, // Account GUID
PropertyId as text, // Property GUID
ViewId as text // View GUID
) =>
let
Source = GoogleAnalytics.Accounts(),
Account = Source{[Id=AccountId]}[Data],
Property = Account{[Id=PropertyId]}[Data],
View = Property{[Id=ViewId]}[Data],

//** DIMENSIONS **//
// Date Dimension
vDate = {Cube.AddAndExpandDimensionColumn, "ga:date", {"ga:date"}, {"Date"}},
vUserType = {Cube.AddAndExpandDimensionColumn, "ga:userType", {"ga:userType"}, {"User Type"}},
vGender = {Cube.AddAndExpandDimensionColumn, "ga:userGender", {"ga:userGender"}, {"Gender"}},
vAge = {Cube.AddAndExpandDimensionColumn, "ga:userAgeBracket", {"ga:userAgeBracket"}, {"Age"}},
vSocialNetwork = {Cube.AddAndExpandDimensionColumn, "ga:socialNetwork", {"ga:socialNetwork"}, {"Social Network"}},

//** MEASURES **//
// PageViews Measure
vPageViews = {Cube.AddMeasureColumn, "Pageviews", "ga:pageviews"},
// NewUsers Measures
vNewUsers = {Cube.AddMeasureColumn, "New Users", "ga:newUsers"},
// Hits Measures (Users)
vUsers = {Cube.AddMeasureColumn, "Users", "ga:users"},

//** CREATE QUERY **//
addDimensions = Cube.Transform(View,
//You have to susbstitute this part with a your new query (dimensions, metrics) and create a new function for each query. Just create the query as a simple table and copy it here.
{
// vSocialNetwork,
// vAge,
// vGender,
// vUserType,
vDate,
vPageViews,
vUsers,
vNewUsers

})
in
addDimensions
in fnGetGAData
```

0 comments on commit 09bd7c3

Please sign in to comment.