1

I need to get a goal name using google analytics API. I'd like to display this name along with some dimensions such as ga:goalCompletionsAll, ga:goalValueAll but I'm unable to.

I have done some research and all I could find are the explanations here Not getting Goal name using Google Analytics gapi but I'm using coldfusion and http requests to make the API call.

I know that I need to use the Management API to get the goal names and the Core Reporting API for other dimensions. I've done the API calls for both and looked at both responses and I'm unable to connect both results i.e the goal name and dimensions.

Kindly assist and thanks in advance

Community
  • 1
  • 1
Simonynsky
  • 13
  • 5
  • If you've already made the calls to the API successfully there should not be a problem to connect both the result. They are linked with `goalID` attribute. You can update the question with your attempt so far and where you're actually facing issue connecting the data – Anurag Mar 08 '16 at 07:08
  • Hi @Anurag. Thanks for your response. Actually there's no goalID in the analytics api response. The only things common in both responses are the profile id, account id and web property id. Here's my analytics api call https://www.googleapis.com/analytics/v3/data/ga?ids=ga:XXX&metrics=ga:goalCompletionsAll,ga:goalValueAll,ga:goalConversionRateAll,ga:goalAbandonRateAll&start-date=7daysAgo&end-date=todaywhere "XXX" is the profileID It's difficult to state which data belongs to which goal if I use profile id, account id and web property id to make the call to get goal names – Simonynsky Mar 08 '16 at 07:46

1 Answers1

2

The reporting API doesn't return the name of the goal. You will need to go though the Management API.

goals.list returns a list of goals for the authenticated user. Then you can check if the goal nr is 1 what the name of it.

Note: Remember goal names can change over time so you cant really store these.

You should have two lists your the metrics you are requesting and the results of the goals.list. Currently there are only XX goal columns for metrics this may change in the future who knows. You will need to test your metrics to find out which number they selected. Depending upon what your application is allowing you can end up with several goals selected in one request.

You want to look at goal.id and goal.name. Goal id is the number.

My application is C# so I cant really share with you how I am handling this.

DaImTo
  • 72,534
  • 21
  • 122
  • 346
  • Thanks @DalmTo. True the reporting API doesn't return the name of the goal. My application does return several goals in one request. The challenge is to get the specifics. I'll try this out and get back here if it doesn't work. – Simonynsky Mar 08 '16 at 14:31
  • My application only lets you pick one. so it was easer. you could do some regex magic to find the number. Also consider supporting goal dimensions who knows if they will add them someday. – DaImTo Mar 09 '16 at 08:36
  • @DaImTo Thanks for this answer. How do I breakdown the metrics by Goal ID? I'm using the query exporter and cannot seem to figure it out on my own. https://ga-dev-tools.appspot.com/query-explorer/ – Cole Feb 25 '20 at 21:40