Retrieving a specific profile from registered accounts using the GData.NET Analytics 2.4 API

In a previous post, I found out how to get metric data for a specific profile identifier: An exception that occurred while using the GData.NET Analytics APIs

Now I would like to get the identifier of a specific profile that corresponds to the registered domain name in the list of my accounts in Google Analytics, this was easy before, but after the last update of Google to Management / Core Reporting API 3.0 the old file 2.3 was disabled and the code associated with an AccountsFeed account, does not work as expected.

+1
gdata google-analytics-api
Sep 03 '12 at 2:16
source share
1 answer

Using the offer posted here: http://code.google.com/p/gdata-issues/issues/detail?can=2&start=0&num=100&q=&colspec=API%20ID%20Type%20Status%20Priority%20Stars%20Summary&groupby= & sort = & id = 2955 , I came up with this code to execute what I need:

Imports Google Imports Google.Analytics Imports Google.GData.Analytics Imports System.Collections.Generic Imports System.Collections Public Function GetProfileId(ByVal DomainText As String) As String Dim Ids As String = String.Empty Dim service As GData.Analytics.AnalyticsService = New GData.Analytics.AnalyticsService("MyAnalyticsService") service.setUserCredentials(username, pass) //Dim factory As GData.Client.GDataGAuthRequestFactory = CType(service.RequestFactory, GData.Client.GDataGAuthRequestFactory) //factory.AccountType = "GOOGLE" //factory.UseSSL = True //service.RequestFactory = factory Dim aF As DataFeed = service.Query(New DataQuery("https://www.googleapis.com/analytics/v2.4/management/accounts")) Dim webPropsUrl As String = "" For Each o As GData.Client.AtomEntry In aF.Entries //webproperties If o.Title.Text.Contains(DomainText) Then webPropsUrl = o.Links.Item(1).HRef.Content Exit For End If Next Dim wpF As DataFeed = service.Query(New DataQuery(webPropsUrl)) Dim profileFeedUrl As String = "" For Each entry As DataEntry In wpF.Entries //profiles profileFeedUrl = entry.Links.Item(2).HRef.Content Exit For Next Dim prF As DataFeed = service.Query(New DataQuery(profileFeedUrl)) Dim profileUrl As String = "" For Each profd As DataEntry In prF.Entries profileUrl = profd.Links.Item(0).HRef.Content Exit For Next Dim profileId As String = "" profileId = profileUrl.Split("/")(profileUrl.Split("/").Length - 1) Return profileId End Function 
+1
Sep 03 '12 at 2:16
source share



All Articles