C# Class GoogleAnalyticsUtils.AnalyticsReporter

Client for the the Google Analytics Measurement Protocol service, which makes HTTP requests to publish data to a Google Analytics account

Inheritance: IAnalyticsReporter
Show file Open project: GoogleCloudPlatform/google-cloud-visualstudio Class Usage Examples

Public Methods

Method Description
AnalyticsReporter ( string propertyId, string appName, string clientId = null, string appVersion = null, bool debug = false, string userAgent = null, IHitSender sender = null ) : System

Initializes the instance.

ReportEndSession ( ) : void

Reports that the session is ending.

ReportEvent ( string category, string action, string label = null, int value = null ) : void

Convenience method to report a single event to Google Analytics.

ReportPageView ( string page, string title, string host, string>.Dictionary customDimensions = null ) : void

Reports a page view hit to analytics.

ReportScreen ( string name ) : void

Reports a window view.

ReportStartSession ( ) : void

Reports that the session is starting.

Private Methods

Method Description
GetCustomDimension ( int index ) : string
MakeBaseHitData ( ) : string>.Dictionary

Constructs the dictionary with the common parameters that all requests must have.

Method Details

AnalyticsReporter() public method

Initializes the instance.
public AnalyticsReporter ( string propertyId, string appName, string clientId = null, string appVersion = null, bool debug = false, string userAgent = null, IHitSender sender = null ) : System
propertyId string The property ID to use, string with the format US-XXXX. Must not be null.
appName string The name of the app for which this reporter is reporting. Must not be null.
clientId string The client id to use when reporting, if null a new random Guid will be generated.
appVersion string Optional, the app version. Defaults to null.
debug bool Optional, whether this reporter is in debug mode. Defaults to false.
userAgent string Optiona, the user agent to use for all HTTP requests.
sender IHitSender The instance of to use to send the this.
return System

ReportEndSession() public method

Reports that the session is ending.
public ReportEndSession ( ) : void
return void

ReportEvent() public method

Convenience method to report a single event to Google Analytics.
public ReportEvent ( string category, string action, string label = null, int value = null ) : void
category string The category for the event.
action string The action that took place.
label string The label affected by the event.
value int The new value.
return void

ReportPageView() public method

Reports a page view hit to analytics.
public ReportPageView ( string page, string title, string host, string>.Dictionary customDimensions = null ) : void
page string The URL to the page.
title string The page title.
host string The page host name.
customDimensions string>.Dictionary Custom dimensions to add to the hit.
return void

ReportScreen() public method

Reports a window view.
public ReportScreen ( string name ) : void
name string The name of the window. Must not be null.
return void

ReportStartSession() public method

Reports that the session is starting.
public ReportStartSession ( ) : void
return void