Ready to get started?

Download a free trial of the Google Analytics Cmdlets to get started:

 Download Now

Learn more:

Google Analytics Icon Google Analytics Cmdlets

An 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.

Pipe Google Analytics Data to CSV in PowerShell



Use standard PowerShell cmdlets to access Google Analytics tables.

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.

Creating a Connection to Your Google Analytics Data

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, you will need to 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"

Selecting Data

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.