Google Analytics

Local plugins ::: local_ganalytics
Maintained by FredFred Woolard
Google Analytics with custom dimensions and metrics.
Latest release:
373 sites
64 downloads
32 fans
Current versions available: 2

Google Analytics local plugin for Moodle

Important! If you plan to use the custom dimension/metric feature...

You should be more than just familiar with Google Analytics, its configuration, and reporting before you install this plugin. Neither this plugin nor its documentation will provide information or tutorials on using or configuring Google Analytics.

If you have no use for custom dimensions or metrics, then you do not need this plugin; instead, place the standard Google generated code snippet in the Site Administration->Appearance->Additional HTML->Within HEAD setting.

Build Status Travis-CI Status

Description

This local plugin generates the JavaScript tracking code snippet for Google Analytics and places it in the <head> element for every page. Besides the pageview hit, it also generates the necessary calls to send custom dimensions and metrics. Programming is still required to get the values you wish to send for your dimensions and metrics, however this plugin provides a simple templated drop-in method to send those values.

Included are four custom dimension samples: user role, course (short) name, coded enrollment size [xs (1-10), sm (11-20), md (21-35), lg (36-50), xl (51+) ], and course category name, associated with custom dimension index slots 1, 2, 3, and 4, respectively. To gather other custom dimension values, edit the code in the custom_dimension_n class to suit your needs. To add another custom dimension, change the plugin settings to indicate how many dimensions should be sent, and then provide the custom_dimension_n class to provide the value; do likewise with custom metrics. If you want to remove a dimension or metric, remove or rename the class file so the class loader does not detect it (likely will require purging all caches).

Privacy & GDPR

This plugin reports it transmits a user's course role, the course name, course category name, and the coded course enrollment size---the custom dimension sample code as published---to an external service, Google Analytics. If the code is altered, it is the site operator's responsibility to update the Moodle Privacy API calls to reflect which user data is being sent. Sending personally identifiable user information to GA is prohibited by Google (see https://support.google.com/analytics/answer/2795983?hl=en).

Caching

The plugin creates a session cache, and an application cache so you can store often used but unchanging data when fetching custom dimension and metric values. Examples of this can be seen in custom_dimension_1 (user role) and custom_dimension_3 (enrollment size). Keep in mind, this plugin is called for every page request and has the potential to severely degrade site response time. Make every effort to be frugal with the $DB calls too.

Configuration

Property ID

Enter the Google property ID for this site.

API

The plugin can generate code to use either the older Universal Analytics (analyticsjs) API, or the newer Global Site Tag (gtagjs) API. While the plugin generates calls to send custom dimension and metric values for either API, at the time of this writing, the gtagjs API does not appear to associate the values with the corresponding pageview hit. Unless you are familiar with setting up dimensions and metrics with Google Tag Manager, or have a need to use gtagjs, recommend to use the default Universal Analytics (analyticsjs).

Dimensions and metrics

Indicate the highest index number of each. This tells the plugin how many custom classes for which to look. If you no longer wish to send a particular dimension or metric which is not last in the list (i.e. ordinal lower than the Nth item), you can remove that custom class file so it is not detected by the auto-loader (cache purge required).

Other dimensions samples

Additional dimensions code samples can be found here.

Potential privacy issues

Google Analytics. This plugin reports it transmits a user's course role, the course name, course category name, and the coded course enrollment size---the custom dimension sample code as published---to an external service, Google Analytics. If the code is altered, it is the site operator's responsibility to update the Moodle Privacy API calls to reflect which user data is being sent. Sending personally identifiable user information to GA is prohibited by Google (see https://support.google.com/analytics/answer/2795983?hl=en).

Screenshots

Screenshot #0
Screenshot #1
Screenshot #2
Screenshot #3

Contributors

Fred
Fred Woolard (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Parādīt komentārus
  • Plugins bot
    piektd., 2018. gada 30. nov.., 00:20
    Approval issue created: CONTRIB-7550
  • Fred
    otrd., 2019. gada 18. jūn.., 05:22
  • Dinesh Ram
    pirmd., 2020. gada 13. jūl.., 22:09
    Get more information about blogging and moreover about space science
    http://randomscience.in
  • Fred
    piektd., 2021. gada 18. jūn.., 06:33
    In the 0.0.5 release there are three additional custom dimension class files for page type, module name, and module instance. In order to use these, remember to change the dimension index setting so they will be included, and the GA property custom data configuration will need to be updated as well.
  • Ben Haensel
    trešd., 2022. gada 22. jūn.., 04:03
    When will this be updated to work with Google Analytics 4 and Moodle 4+? Thanks! -Ben
  • Mark Baldwin
    otrd., 2024. gada 20. aug.., 19:25
    Hi - would also love to know if this is being updated for Moodle 4+? Thanks in advance.
  • Rouhollah Bakhshi
    svētd., 2024. gada 20. okt.., 14:10
    I hope this message finds you well.

    We are currently using your Google Analytics plugin for Moodle version 3.11, and it has been an invaluable tool for our platform. However, we are in the process of upgrading to Moodle version 4.4 and would greatly appreciate an updated version of the plugin that is compatible with this new release.

    Given the enhancements and improvements in Moodle 4.4, it would be extremely beneficial to have your plugin support this version as well, ensuring that we can continue leveraging its functionalities without interruption.

    Please let us know if an update is planned, and if possible, the expected release timeline. We are very keen to continue using your plugin and would be happy to offer any feedback or assistance needed during the development process.

    Thank you in advance for your time and efforts. We look forward to hearing from you.

    Best regards,
Please login to post comments