Difference between revisions of "Google Analytics"

From NCBO Wiki
Jump to: navigation, search
(Created page with "Category:NCBO Virtual Appliance = Adding Google Analytics to the BioPortal Appliance = == Google developer account == The Google API to process our website data. Create...")
 
(forwarded to new content)
Line 1: Line 1:
 
[[Category:NCBO Virtual Appliance]]
 
[[Category:NCBO Virtual Appliance]]
  
= Adding Google Analytics to the BioPortal Appliance =
+
This content has been moved! Please find the new content for the 3.0 version of the Virtual Appliance at our new [https://ontoportal.github.io/administration/ OntoPortal Virtual Appliance Administration pages].
+
== Google developer account ==
+
The Google API to process our website data. Create an account at https://console.developers.google.com/project
+
* Create an account
+
* Generate credentials (p12 key & email) and save it for later
+
** API Manager > Credentials > Add credentials > Service account
+
** Note: default password of the p12 keys is notasecret
+
+
* Enable Analytics API
+
** API Manager > Overview > Advertising APIs > Analytics API
+
  
* Copy p12 keys to the appliance (in the /srv directory for example)
+
In particular this content is mostly at the [https://ontoportal.github.io/administration/management/google_analytics_management/ Google Analytics Management page].
** Example: scp mybioportal-ffad56jdic91ky.p12 my_bioportal_va:/srv/
+
+
== Google analytics account ==
+
Get our website data. Create an account at https://www.google.com/analytics/web
+
* Create an account
+
* Add the "tracking ID" of this account in /srv/rails/BioPortal/current/config/bioportal_config_production.rb
+
** Example:  `$ANALYTICS_ID = "UA-63691424-3"`
+
 
+
* Give permission to your developer credential (previously generated at the console.developer step) to be able to retrieve the data
+
** Admin tab > Property (in general, it is the website your doing analytics on) > User Management
+
** Add permissions for the google developer credential email (generated in the previous section)
+
 
+
* Add in /srv/ncbo/ontologies_api/current/config/environments/appliance.rb & /srv/ncbo/ncbo_cron/config/appliance.rb
+
 
+
<code>
+
  LinkedData.config do |config|
+
  config.enable_ontology_analytics = true
+
  end
+
  NcboCron.config do |config|
+
  config.enable_ontology_analytics = true
+
  config.cron_ontology_analytics  = "30 */4 * * *"
+
  # Google Analytics config
+
  config.analytics_service_account_email_address = "account-1@mybioportal-1145.iam.gserviceaccount.com" # The email address you get when creating the google developer account
+
  config.analytics_path_to_key_file              = "/srv/agroportal-ffad56jdic91ky.p12" # you have to get this file from the first step
+
  config.analytics_profile_id                    = "ga:111821946" # replace with your ga view id
+
  config.analytics_app_name                      = "mybioportal"
+
  config.analytics_app_version                  = "1.0.0"
+
  config.analytics_start_date                    = "2015-10-01"
+
  config.analytics_filter_str                    = ""
+
  end
+
</code>
+
+
= Tests using API explorer =
+
 
+
https://developers.google.com/apis-explorer/#search/analytics/m/analytics/v2.4/analytics.data.get
+
 
+
https://ga-dev-tools.appspot.com/query-explorer/
+
 
+
<code>
+
  id = ga:111821946
+
  start-date = 30daysAgo
+
  end-date = yesterday
+
  metrics = ga:pageviews
+
  dimensions = ga:pagePath,ga:year,ga:month
+
  filters
+
</code>
+
 
+
= Removing Analytics from UI =
+
 
+
* In /srv/rails/BioPortal/current/app/views/home/index.html.haml add:
+
 
+
<code>
+
  display: none;
+
  %fieldset{style: "display: none;"}
+
  %legend
+
    Ontology Visits #{"in full #{$SITE} " if at_slice?} (#{@analytics.date.strftime("%B %Y")})
+
</code>
+
 
+
* In /srv/rails/BioPortal/current/app/views/ontologies/_visits.html.haml add:
+
 
+
<code>
+
  display:none;
+
  #visits_content{:style => "margin: 2em 1em 0;"}
+
</code>
+

Revision as of 18:09, 12 June 2020


This content has been moved! Please find the new content for the 3.0 version of the Virtual Appliance at our new OntoPortal Virtual Appliance Administration pages.

In particular this content is mostly at the Google Analytics Management page.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox