Referencing custom google analytics metric on a dashing dashboard

I have a dashing dashboard set up which I have showing the "ga:activeVisitors' metric. This works fine and I've no problems there. My question is how do I show a different stat that my ga is capturing for example... On one of my GA dashboards I have a widget showing a real time value of another metric. How would I reference that instead of the ga:activeVisitors metric?

my code is as follows:

require 'google/api_client'
require 'date'

# Update these to match your own apps credentials
service_account_email = '[email]' # Email of service account key_file = '[key file path]' # File containing your private key key_secret = 'secret' # Password to unlock private key profile_id = 'profile' # Analytics profile ID.

# Get the Google API client
client =
:application_name => '[app name]',
:application_version => '0.01'

visitors = []

# Load your credentials for the service account
key = Google::APIClient::KeyUtils.load_from_pkcs12(key_file, key_secret)
client.authorization =
:token_credential_uri =>  '',
:audience => '',
:scope => '',
:issuer => service_account_email,
:signing_key => key)

# Start the scheduler
SCHEDULER.every '1s', :first_in => 0 do

# Request a token for our service account

# Get the analytics API
analytics = client.discovered_api('analytics','v3')

# Execute the query
response = client.execute(:api_method =>,   :parameters => {
'ids' => "ga:" + profile_id,
'metrics' => "ga:activeVisitors",

visitors << { x:, y: }

# Update the dashboard
send_event('visitor_count_real_time', points: visitors)


To access real time data you need to use the Real-time api.

the real time api has a different set of dimensions and metrics then the core reporting api you will need to use those. which it looks like you are ga:activeVisitors

The Real Time Reporting API is currently available as a developer preview in limited beta. If you're interested in signing up, request access to the beta.

it normally takes 24 hours to get access you will not hear anything from google you should just try and make a request.

I am not a ruby programmer but your code: looks correct to me. Are you getting any errors?

On the following website you will find GA Queries Examples:

Maybe it helps you?

Need Your Help

Using React-Router to link within a page

javascript html reactjs react-router

I'm trying to make an anchor tag which will link to a location within the same page (like this)

Jquery working in Firefox but not Internet Explorer

javascript jquery internet-explorer firefox

I'm using the jQuery Cycle plugin ( on this page: