@LindaLawtonDK Do you plan to do one of your fab tutorials on the new Search Analytics API for Webmasters? I’m stuck! http://goo.gl/4usHJK
fab tutorials really? I do get emails now and then and the site generates a handful of comments every week. However I often wonder how many people I help. I am on twitter and Google+ if you like what i am doing feel let me know I would really appreciate it. Heck even if you don’t like what I am doing let me know and maybe I can fix what ever it is you think is wrong.
So by request. I give you
WebMaster Tools API with C#
Create a visual studio project .net framework 4.0 or 4.5. Import the following Nuget Package
I have included both the Service account and the Oauth2 authentication methods below.
To call the Oauth2 method you would do something like this. Remember CLIENT_ID and CLIENT_SECRET can be found on the Google Developers console.
var service = Authentication.AuthenticateOauth(CLIENT_ID, CLIENT_SECRET, "TEST");
To call the service account you will need the serviceAccountEmail and the path to the keyFilePath both values are found on the Google developers console.
var service = Authentication.AuthenticateServiceAccount(string serviceAccountEmail, string keyFilePath)
As always with service accounts they need to be pre-authorized to be able to access the data. We do that on the webMaster Tools website.
One thing that Paul and I found while we where trying to get this working was that, the web master tools website only stores data for 90 days. Dont bother requesting data that’s over 90 days old its probably not there. However if you find that it is there please let me know. I hate the idea of data being deleted.
Paul was working with the Search Analytics: query
Query your search traffic data with filters and parameters that you define. The method returns zero or more rows grouped by the row keys (dimensions) that you define.
IList newlist = new List (); newlist.Add("country"); newlist.Add("device"); SearchAnalyticsQueryRequest body = new SearchAnalyticsQueryRequest(); body.StartDate = "2015-09-01"; body.EndDate = "2015-09-15"; body.Dimensions = newlist; var result = service.Searchanalytics.Query(body, "https://www.daimto.com/").Execute();
"keys": [ "usa", "DESKTOP" ], "clicks": 665, "impressions": 23211, "ctr": 0.02865020895265176, "position": 9.619318426608073
Google WebMaster tools API returns some analytical data that Google Analytics doesn’t have. If it is true that the webmaster tools API does delete data over 90 days old I think it would be a good idea to export as much of this information as possible before it is lost for ever. Search Analytics could be very valuable.
The question on stackOverflow can be found here .Net struggles with Webmaster Tools (Google.Apis.Webmasters.v3 Nuget package) Paul apparently really likes long stack question titles.
I also have a sample project that I created ages ago for working with the WebMaster Tools API I will try and update it asap to add this. Google-dotnet-samples