Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9243987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:55:33+00:00 2026-06-18T08:55:33+00:00

Im using this code from google api I am getting all of the goals

  • 0

Im using this code from google api

I am getting all of the goals names and number

But I cant see a way to get the goal completed amount

This is what I get:

            Account ID               = xxx
            Web Property ID          = xxx
            Internal Web Property ID = xxx
            Profile ID               = xxx


            Goal Number = 1
            Goal Name   = Open User (MT Register)
            Goal Value  = 0
            Goal Active = 1
            Goal Type   = URL_DESTINATION

            Created = 2012-07-22T10:20:02.183Z
            Updated = 2012-08-15T12:43:06.045Z



Goal URL            = /04_thankyou.php
Case Sensitive      = 
Match Type          = REGEX
First Step Required = 1

Destination Goal Steps


Step Number = 1
Step Name   = abc
  Step URL    = /01_insert_phone.php



Step Number = 2
Step Name   = abcd
  Step URL    = /02_progress.step



Step Number = 3
Step Name   = abcde
  Step URL    = /03_insert_pincode.php

This is the code:

function getEventDetailsHtml(&$details) {
  $html = '<h4>Event Goal</h4><pre>' .
          'Use Event Value = ' . $details->getUseEventValue();

  // Get all the event goal conditions.
  $conditions = $details->getEventConditions();

  foreach ($conditions as &$condition) {
    $html .= "Event Type = $condition->getEventType()";

    $eventType = $condition->getType();
    if ($condition->getType() == 'VALUE') {
      // Process VALUE.
      $html .= "Comparison Type  = $condition->getComparisonType()" .
               "Comparison Value = $condition->getComparisonValue()";

    } else {
      // Process CATEGORY, ACTION, LABEL.
      $html .= "Match Type = $condition->getMatchType()" .
               "Expression = $condition->getExpression()";
    }
  }

  return $html . '</pre>';
}

function getVisitNumPagesDetailsHtml(&$details) {
  $html = '<h4>Visit Num Pages Goal</h4>';
  $html .= <<<HTML
<pre>

Comparison Type  = {$details->getComparisonType()}
Comparison Value = {$details->getComparisonValue()}

</pre>
HTML;
  return $html;
}

function getVisitTimeOnSiteDetailsHtml(&$details) {
  $html = '<h4>Visit Time On Site Goal</h4>';
  $html .= <<<HTML
<pre>

Comparison Type  = {$details->getComparisonType()}
Comparison Value = {$details->getComparisonValue()}

</pre>
HTML;
  return $html;
}

function getUrlDestinationDetailsHtml(&$details) {
  $html .= <<<HTML

<pre>

Goal URL            = {$details->getUrl()}
Case Sensitive      = {$details->getCaseSensitive()}
Match Type          = {$details->getMatchType()}
First Step Required = {$details->getFirstStepRequired()}

</pre>
HTML;

  $html .= '<h4>Destination Goal Steps</h4>';
  $steps = $details->getSteps();
  if (count($steps) == 0) {
    $html .= '<p>No Steps Configured</p>';

  } else {
    foreach ($steps as &$step) {
      $html .= <<<HTML
<pre>

Step Number = {$step->getNumber()}
Step Name   = {$step->getName()}
  Step URL    = {$step->getUrl()}

  </pre>
HTML;
    }
  }
  return $html;
}

    require_once 'google_api.php';

    if (isset($_SESSION['token'])) { 
        $client->setAccessToken($_SESSION['token']); 
    }

    if (!$client->getAccessToken()) {
      $authUrl = $client->createAuthUrl();
      print "<a class='login' href='$authUrl'>Connect Me!</a>";

    } else {
      $analytics = new Google_AnalyticsService($client);

        try {
          $goals = $analytics->management_goals
                             ->listManagementGoals('25788360',
                                                   'UA-25788360-20',
                                                   '~all');

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

        $html = '';
$items = $goals->getItems();
  foreach ($items as &$goal) {
    $html .= "
            <pre>
            Account ID               = {$goal->getAccountId()}
            Web Property ID          = {$goal->getWebPropertyId()}
            Internal Web Property ID = {$goal->getInternalWebPropertyId()}
            Profile ID               = {$goal->getProfileId()}


            Goal Number = {$goal->getId()}
            Goal Name   = {$goal->getName()}
            Goal Value  = {$goal->getValue()}
            Goal Active = {$goal->getActive()}
            Goal Type   = {$goal->getType()}

            Created = {$goal->getCreated()}
            Updated = {$goal->getUpdated()}
            </pre>";

    // Now get the HTML for the type of goal.
    switch($goal->getType()) {
      case 'URL_DESTINATION':
        $html .= getUrlDestinationDetailsHtml(
            $goal->getUrlDestinationDetails());
        break;

      case 'VISIT_TIME_ON_SITE':
        $html .= getVisitTimeOnSiteDetailsHtml(
            $goal->getVisitTimeOnSiteDetails());
        break;

      case 'VISIT_NUM_PAGES':
        $html .= getVisitNumPagesDetailsHtml(
            $goal->getVisitNumPagesDetails());
        break;

      case 'EVENT':
        $html .= getEventDetailsHtml(
            $goal->getEventDetails());
        break;
  }

    echo $html;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:55:34+00:00Added an answer on June 18, 2026 at 8:55 am

    It seems like you are using the Management API. This is meant for management purposes only. Getting and setting goals.

    If you want data from goals as well you want to be looking at the Core Reporting API.

    The available data for goals can be found here:
    https://developers.google.com/analytics/devguides/reporting/core/dimsmets/goalconversions

    The implementation guide can be found here:
    https://developers.google.com/analytics/devguides/reporting/core/v3/coreDevguide

    I did not provide a full implementation example seeing that you already know how to setup the use of a Google API.

    Good luck with you quest!

    EDIT:
    Added an example on how to use it:

    <?php
    $client = new apiAnalyticsService();
    
    function queryCoreReportingApi() {
        $optParams = array( //OPTINAL SETTINGS
          'dimensions' => '', //A comma-separated list of Multi-Channel Funnels dimensions. E.g., 'mcf:source,mcf:medium'. (string)
          'sort' => '', //A comma-separated list of dimensions or metrics that determine the sort order for the Analytics data. (string)
          'filters' => '', //A comma-separated list of dimension or metric filters to be applied to the Analytics data. (string)
          'start-index' => '', //An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter. (integer, 1+)
          'fields' => '', //Selector specifying which fields to include in a partial response.
          'max-results' => '25'); //The maximum number of entries to include in this feed. (integer)
    
      return $service->data_mcf->get(
          $id, //Unique table ID for retrieving Analytics data. Table ID is of the form ga:XXXX, where XXXX is the Analytics profile ID. (string)
          '2010-01-01', //Start date for fetching Analytics data. All requests should specify a start date formatted as YYYY-MM-DD. (string)
          '2010-01-15', //End date for fetching Analytics data. All requests should specify an end date formatted as YYYY-MM-DD. (string)
          'ga:totalConversions', //A comma-separated list of Multi-Channel Funnels metrics. E.g., 'mcf:totalConversions,mcf:totalConversionValue'. At least one metric must be specified. (string)
          $optParams);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting driving distance from google map api v3 using this code. distance11
I'm using this code to read the connection string from my app.config file but
This is my first attempt at using the Google Data API, and I'm getting
I am using http://code.google.com/apis/maps/documentation/geocoding/ api from google to get geolocation based on address. I
I am using this code from css tips and tricks to cover a background
I am using this code taken from here : import smtplib def prompt(prompt): return
I am using this code phone calling from iPhone its calling directly to particular
When using this code (simplified for asking): var rows1 = (from t1 in db.TABLE1
I'm using this code to extract text from the database and it works well
I am using this code to pull my string array from my values folder:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.