Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Accessing Google Analtyics with v3 client library is really nice tbh. The only thing i havent worked out is how to send it a refreshtoken i have stored in the database. Im stuck with the one it stores for me on the Pc. </p> <p>Request autentication: All the client scret stuff is stored in client_secret.json you can download the file from google apis consol. It will pop up a browser window if it doesnt have approval if it does it will just continue on.</p> <pre><code>private void Form1_Load(object sender, EventArgs e) { UserCredential credential; using (var stream = new System.IO.FileStream("client_secret.json", System.IO.FileMode.Open, System.IO.FileAccess.Read)) { credential = GoogleWebAuthorizationBroker.AuthorizeAsync( GoogleClientSecrets.Load(stream).Secrets, new[] { AnalyticsService.Scope.AnalyticsReadonly }, "user", CancellationToken.None, new FileDataStore("Analytics.Auth.Store")).Result; } </code></pre> <p>}</p> <p>Now to access Google Analytics you need to make an analytics Service.</p> <pre><code>AnalyticsService service = new AnalyticsService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = "Analytics API sample", }); </code></pre> <p>All your calls will now be run against that. </p> <p>Yours should end up being something like:</p> <pre><code>DataResource.GaResource.GetRequest request = service.Data.Ga.Get(ga:34197921, new DateTime(2012, 1, 2).ToString("yyyy-MM-dd"), DateTime.Now.ToString("yyyy-MM-dd"), ""ga:visits,ga:visitors,ga:visitBounceRate,ga:goalStartsAll,ga:goalCompletionsAll,ga:goal1Starts,ga:goal1Completions,ga:goal2Starts,ga:goal2Completions,ga:goal3Starts,ga:goal3Completions,ga:goal4Starts,ga:goal4Completions,ga:adCost,ga:totalValue"); request.Dimensions = "ga:medium,ga:campaign,ga:date,ga:isMobile,ga:isTablet,ga:searchKeyword,ga:hostname"; </code></pre> <p>I have a blog post that runs though most of the diffrent calls you can make. <a href="http://daimto.com/google-analytics-api-v3-with-c/" rel="nofollow">http://daimto.com/google-analytics-api-v3-with-c/</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload