Documentation and code to publicly and dynamically display usage information (e.g. from Google Analytics, YouTube) for courses, resources, and associated materials in OERbit.
This repository contains a Drupal module built to pair with the OERbit framework developed by Open.Michigan. It gets YouTube and Google Analytics of the media/web pages published on the Open.Michigan website and displays them in a block, as a themed list (in the current iteration, you may use the Context module to choose where it appears).
Module CURRENTLY IN DEVELOPMENT and pending significant updates.
This module depends on the OAuth module, the Google Analytics API module, the Google Analytics Counter module and the Elysia Cron module.
-
Make sure you have the dependencies installed: elysia_cron googleanalytics (contained in Google_Analytics_Reports, but you do NOT have to install Reports' dependencies) google_analytics_api google_analytics_counter
-
Configure dependencies as necessary.
-
For the Google Analytics API, in the admin settings, click the "setup" button, then choose the correct profile (assuming all the other things for your Google Analytics are set up)
-
Register for an API Key at the Google API Console if you do not have one.
-
at
admin/settings/oer-analytics
in your Drupal site (OERbit install), paste the API key in that text box, and hit save.Note that the current setup of this module depends on a database structure like that which Open.Michigan's instance of OERbit uses and may need significant modification for other use as it stands.
- Install the module:
From GitHub:
cd
to the sites/all/modules
folder of your OERbit instance.
git clone https://github.com/openmichigan/oerbit_analytics.git oer_analytics
in that folder.
- Add block to the correct Context.
Go to Context > List > click "Edit" in 'education section/course' (a special OERbit thing) > Blocks > add oer_analytics to Course Navigation
That's all! (Check PHPMyAdmin/your database, and your install, to be sure it is working as expected)
As for what is actually going on as the module 'grabs the info and displays it in a block':
The arrows in the diagram, you'll notice, are labeled with numbers -- the approximate order in which processes are happening behind the scenes.
-
OERbit queries the database for information (specifically, YouTube video IDs and the Drupal node IDs with which they are associated)
-
A call is made to the YouTube Data API (v3), using the information gathered from the database, in order to get information e.g. # of views per video.
-
The aggregated information from steps (1) and (2) is properly aggregated and stored in new database tables for the oer_analytics module.
-
This is the 'fourth part' of the process, but it is really operating on a slightly different timeline: leveraging the Google Analytics API module via the Google Analytics Counter Module, both of which this currently depends on, to grab Google Analytics data for the correct pages in the setup G.A. (Google Analytics) profile. Specifically, this module will grab views for every page of node type course (defined in OERbit ), and for each course which has a bulk download, loads of the bulk download page for that course. (Further updates pending.)
-
All this information, whether from the database, live API responses, or cache, is aggregated properly (represented by arrow 5) and displayed (6).
-
TODO: Make functionality more modularizable (e.g. easier to pick out different likely desired pieces of information in the Google Analytics section of the
oer_analytics.module
file without digging too much into the code) -- G.A. code in particular will be refactored after first live release. -
TODO: Further display decisions, increased user-friendliness for multiple uses
-
TODO: Integration of JavaScript charts
-
TODO: more testing, + feature??
(for now) See oer_analytics.module