The ADO.NET provider for Google Analytics provides a wide range of features that enable connectivity to Google Analytics from .Net applications . The documentation will help you understand the C1.AdoNet.GoogleAnalytics namespace, which includes all the available classes that can be used to connect and retrieve data from Google Analytics
DataConnectors are mostly used in combination with other ComponentOne components, such as DataEngine and FlexPivot. The procedure below describes the first steps to use the DataConnector in a console application within Visual Studio.
The ADO.NET provider for Google Analytics can be used in any application. In this guide, a console application is created:
To use the ADO.NET provider for Google Analytics in an application, the respective NuGet package should be added:
Follow the steps provided below to learn and implement data retrieval using ADO.NET provider for Google Analytics.
C# |
Copy Code |
---|---|
const string KeyFile = "*******"; const string ViewId = "************"; |
C# |
Copy Code |
---|---|
static void ReadData() { //Define connection string string connectionString = string.Format("Key File={0};View Id={1}", KeyFile, ViewId); //Define command string sql = "SELECT Source, Sessions FROM Traffic WHERE Sessions > 500 AND StartDate = '14DaysAgo' AND EndDate = 'Today'"; //Fetch data using (var con = new C1GoogleAnalyticsConnection(connectionString)) { con.Open(); var command = con.CreateCommand(); command.CommandText = sql; var reader = command.ExecuteReader(); while (reader.Read()) { Console.WriteLine(String.Format("{0} --> \t\t{1}", reader["Source"], reader["Sessions"])); } } } |