1
votes

I got the confirmation Email regarding project whitelisting from Google Analytics team and tried inserting a Goal but got the error.

{The service analytics has thrown an exception: Google.GoogleApiException: Google.Apis.Requests.RequestError
Your project does not have access to this feature. [403]
Errors [
        Message[Your project does not have access to this feature.] Location[ - ] Reason[insufficientPermissions] Domain[global]
]

   at Google.Apis.Requests.ClientServiceRequest`1.<ParseResponse>d__34.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Google.Apis.Requests.ClientServiceRequest`1.Execute()}

I'm using the Google.Apis.Analytics.v3 (1.32) nuget package for creating the goal

The code I've written is:

            var goal = new Goal();
            goal.AccountId = accId;
            goal.WebPropertyId = websiteId;
            goal.ProfileId = profileId;

            goal.Name = "Api Funnel";
            goal.Active = true;
            goal.Created = new DateTime();


            goal.Type = "URL_DESTINATION";
            var urlDestinationDetails = new UrlDestinationDetailsData();
            urlDestinationDetails.MatchType = "EXACT";

            var stepData0 = new UrlDestinationDetailsData.StepsData();
            stepData0.Number = 0;
            stepData0.Url = "step1";
            stepData0.Name = "Step1";

            var stepData1 = new UrlDestinationDetailsData.StepsData();
            stepData1.Number = 0;
            stepData1.Url = "step2";
            stepData1.Name = "Step2";

            var steps = new List<UrlDestinationDetailsData.StepsData>();

            urlDestinationDetails.Steps = steps;
            goal.UrlDestinationDetails = urlDestinationDetails;
            goal.UrlDestinationDetails.Url = "step2";
            var request = analyticsService.Management.Goals.Insert(goal, accId, websiteId, profileId);
            request.Execute();

Scope is set to analytics.edit :

https://www.googleapis.com/auth/analytics.edit

Still, I'm facing the issue

google analytics management api - Insert goals - 403

Also referred to the respective post but couldn't find any answer.

All the get requests were processed successfully returning the correct data. Now, I want to insert a goal but having this issue.

Also asked using the issue tracker of google

https://issuetracker.google.com/issues/71837169

Also the developer forum group is closed now : https://groups.google.com/forum/?fromgroups#!forum/google-analytics-management-api

Please feel free to ask any additional information.

1
My own experience of using the Google API's is that you need a p12 key and an account. Have you set that up?Matt Evans
@MatthewEvans that is only true if you want to access using a service account its not going to help you access a users data.DaImTo

1 Answers

0
votes

Documentation

Write operations in the Management API (e.g. create, update, delete, patch) for Web Property, View (Profile), and Goal resources are currently available as a developer preview in limited beta. If you're interested in using these features, request access to the beta.

Google Analytics write opernations are in beta. You say that you have applied and been white-listed. You must use the Google Developer Project that you applied with to access it.

Your project does not have access to this feature.

Means that the client id and secrete you are using to authenticate with does not have access to this feature its not part of the project you applied for access with the one that was white listed.