title: How to retrieve the goal name in Analytics using APIs
body: <p>I'm trying to retrieve the name of my Analytics goals through the Google API using PHP. I tried this code but I don't understand why it creates a loop and does not return any value to me.
  Anyone have any ideas?
  Thanks so much</p>
  
  <pre><code>  $goals = $analytics-&gt;management_goals-&gt;listManagementGoals('123456', 'UA-123456-1', '~all');
  
    foreach ($goals-&gt;getItems() as $key) {
        $html = &lt;&lt;&lt;HTML
          &lt;pre&gt;
              Goal id              = {$key-&gt;getId()}
              Goal name            = {$key-&gt;getName()}
              HTML;
        $html .= '&lt;/pre&gt;';
        print $html;
    } 
  </code></pre>