![]() |
VOOZH | about |
The CData Cmdlets Module for Google Analytics is a standard PowerShell module offering straightforward integration with Google Analytics. Below, you will find examples of using our GoogleAnalytics Cmdlets with native PowerShell cmdlets.
Google uses the OAuth authentication standard. To access Google APIs on behalf on individual users, you can use the embedded credentials or you can register your own OAuth app.
OAuth also enables you to use a service account to connect on behalf of users in a Google Apps domain. To authenticate with a service account, register an application to obtain the OAuth JWT values.
In addition to the OAuth values, set Profile to the profile you want to connect to. This can be set to either the Id or website URL for the Profile. If not specified, the first Profile returned will be used.
$conn = Connect-GAnalytics -Profile "$Profile" -InitiateOAuth "$InitiateOAuth"
Follow the steps below to retrieve data from the Traffic table and pipe the result into to a CSV file:
Select-GoogleAnalytics -Connection $conn -Table Traffic | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myTrafficData.csv -NoTypeInformation
You will notice that we piped the results from Select-GoogleAnalytics into a Select-Object cmdlet and excluded some properties before piping them into an Export-Csv cmdlet. We do this because the CData Cmdlets append Connection, Table, and Columns information onto each "row" in the result set, and we do not necessarily want that information in our CSV file.
The Connection, Table, and Columns are appended to the results in order to facilitate piping results from one of the CData Cmdlets directly into another one.Download a free trial of the Google Analytics Cmdlets to get started:
Download NowLearn more:
👁 Google Analytics IconAn easy-to-use set of PowerShell Cmdlets offering real-time access to Google Analytics data. The Cmdlets allow users to easily query live data - just like working with SQL server.