Getting conversions by goal

1

Working with API to manipulate data about conversion , I get the total number of conversions per goal if I explicitly set the metric's API query parameter, as follows:

    $metrics    = 'ga:goal1Completions,ga:goal2Completions,ga:goal3Completions',
   [
        'dimensions'    => 'ga:date',
        'output'        => 'dataTable'
    ]

The problem with doing this is that I do not know how many goals are registered for each client, this varies between 1 and 20. It is not possible to list from 1 to 20, and if I return 0 I treat the line, which is the case of goal 3 in the example, which does not exist.

    
asked by anonymous 16.03.2016 / 13:33

1 answer

1

You must call listManagementGoals Analytics API.

/**
 * Example #1:
 * Requests goals for a single view (profile).
 */
try {
  $goals = $analytics->management_goals->listManagementGoals('123456',
      'UA-123456-1',
      '7654321');

} catch (apiServiceException $e) {
  print 'There was an Analytics API service error '
      . $e->getCode() . ':' . $e->getMessage();

} catch (apiException $e) {
  print 'There was a general API error '
      . $e->getCode() . ':' . $e->getMessage();
}

Based on the response from Matt at SOen .

    
21.03.2016 / 15:42