• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
The Electric Toolbox Blog

The Electric Toolbox Blog

Linux, Apache, Nginx, MySQL, Javascript and PHP articles

  • Applications
  • FCKEditor
  • Apache
  • Windows
  • Contact Us
Home / Article / PHP / Get the Google Analytics profile id from the accounts list

Get the Google Analytics profile id from the accounts list

Just a quick post about an easy way to get the profile id for a Google Analytics account using my PHP Class. The ->load_accounts() function loads the accounts into an associative array which you can then access from ->accounts. The profile id is stored in there.

Here’s a code snippet illustrating this below, where we want to access data for the www.electrictoolbox.com profile:

$api = new analytics_api();
 if($api->login($login, $password)) {
 $api->load_accounts();
 $profile_id = $api->accounts['www.electrictoolbox.com']['tableId'];
 $data = $api->data($profile_id, ...);
 }

Alternatively you don’t need to store it in a separate variable and could do it like this instead:

$api = new analytics_api();
 if($api->login($login, $password)) {
 $api->load_accounts();
 $data = $api->data($api->accounts['www.electrictoolbox.com']['tableId'], ...);
 }

This uses my PHP class which can be downloaded here. More info and other posts about this here.

Check Out These Related posts:

  1. PHP class for using the Google Analytics API
  2. Get the ID for the Google Analytics API IDS parameter
  3. Load the Google Analytics API accounts list with PHP
  4. The Google Analytics API and PHP: A series

Filed Under: PHP

Primary Sidebar

Categories

  • Apache
  • Applications
  • Article
  • Case Studies
  • Email Servers
  • FCKEditor
  • HTML And CSS
  • Javascript
  • Linux/Unix/BSD
  • Microsoft SQL Server
  • Miscellaneous Postings
  • MySql
  • Networking
  • Nginx Web Server
  • Offsite Articles
  • OSX
  • PHP
  • Quick Tips
  • RFC – Request for Comments
  • SilverStripe
  • VMWare
  • VPN
  • Windows
  • WordPress

Recent Posts

  • Vim Show Line Numbers
  • Add User To Group Linux
  • Chmod 777 Tutorial
  • How to Copy Directory Linux
  • Linux create user

Copyright © 2021. ElectricToolBox. All Rights Reserved.

  • Contact Us
  • Copyright Info
  • Privacy Policy
  • Sitemap