How to get conversions per goal

Asked

Viewed 68 times

1

Working with API to handle data on conversion, I can get the total conversions per meta if I make explicit the API query parameter for metric, as follows:

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

inserir a descrição da imagem aqui

The problem of doing this is that I don’t know how many goals are registered for each customer, it varies between 1 and 20. It is unfeasible to list from 1 to 20, and in case it returns 0 i treat the line, which is the case of goal 3 in the example, which does not exist.

1 answer

1


The method must be called listManagementGoals of the 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 of Matt in the Soen.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.