OntoPortal Administration Documentation

Google Analytics Management

Adding Google Analytics to the OntoPortal Virtual Appliance

BioPortal uses the Google API to process our website data.

If you want to use the Google in your OntoPortal site, you will need a Google developer account to use the Google API, and a Google Analytics account to see the analytics. The Google API is used to process the web site’s data.

Google Developer Account

You can create an account at https://console.developers.google.com/project. Use the following steps to do so.

Google Analytics Account

You use Google Analytics to get your website’s data.

    # Google Analytics config
    config.enable_ontology_analytics               = true
    config.cron_ontology_analytics                 = '30 */4 * * *'
    config.analytics_service_account_email_address = 'myontoportal@developer.gserviceaccount.com'
    config.analytics_path_to_key_file              = 'config/myontoportal-analytics.p12'
    config.analytics_profile_id                    = 'ga:1234567'
    config.analytics_app_name                      = 'MyOntoPortal'
    config.analytics_app_version                   = '1.0.0'
    config.analytics_start_date                    = '2020-01-01'
    config.analytics_filter_str                    = ''

Enabling Analytics Cron Job

The Analytics data is stored in Redis data store and is scheduled to be refreshed weekly. The refresh is done via an automatically scheduled Cron job. By default, that Cron job is disabled in the OntoPortal Appliance. Below are the steps to enable the Analytics refresh job:

If you modify this setting, be sure to restart ncbo_cron services (see previous step).

If you need to manually refresh the Analytics data without having to wait for the Cron job to execute, you can run the ncbo_ontology_analytics_rebuild script, located in the ncbo_cron/bin folder:

# sudo su - ontoportal
# cd /srv/ontoportal/ncbo_cron
# ./bin/ncbo_ontology_analytics_rebuild

Note that this script DOES NOT exist in Virtual Appliance versions prior to v3.0.2!

The script does not require any arguments; simply execute it, and your Analytics data will get pulled from Google Analytics into the Redis datastore and will be immediately picked up by your OntoPortal services. Note that this step is optional. It should be used only when you need the absolute latest Analytics data, and you don’t want to wait until the Analytics Cron job gets executed.

Tests using API explorer

Relevant links are

 id = ga:111821946
 start-date = 30daysAgo
 end-date = yesterday
 metrics = ga:pageviews
 dimensions = ga:pagePath,ga:year,ga:month

Removing Analytics from OntoPortal UI

In /srv/ontoportal/bioportal_web_ui/current/app/views/home/index.html.haml add:

 display: none;
 %fieldset{style: "display: none;"}
   Ontology Visits #{"in full #{$SITE} " if at_slice?} (#{@analytics.date.strftime("%B %Y")})

In /srv/ontoportal/bioportal_web_ui/current/app/views/ontologies/_visits.html.haml add:

 #visits_content{:style => "margin: 2em 1em 0;"}