Search code examples
google-analyticscoldfusiongoogle-analytics-apicfhttp

Google Analytics API get Goal name


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


Solution

  • 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.