DavidWells / analytics

Lightweight analytics abstraction layer for tracking page views, custom events, & identifying visitors
https://getanalytics.io
MIT License
2.47k stars 245 forks source link

Plugin request: Umami #149

Closed mgorsk1 closed 3 years ago

mgorsk1 commented 3 years ago

Umami is super simple and popular open-source project for analytics. It provides API to send custom data to it and could potentially be integrated with analytics.

https://github.com/mikecao/umami

DavidWells commented 3 years ago

Umami looks pretty cool.

I won't have time to build this integration myself but you are more than welcome to

See https://getanalytics.io/plugins/writing-plugins/#1-provider-plugins for writing a plugin.

Essentially, you will want to map the page, track methods to the umami JS calls

export default function providerPluginExample(userConfig) {
  return {
    /* All plugins require a name */
    name: 'my-example-plugin',
    /* Everything else below this is optional depending on your plugin requirements */
    config: {
      whatEver: userConfig.whatEver,
      elseYouNeed: userConfig.elseYouNeed
    },
    initialize: ({ config }) => {
      // load umami script to page
    },
    page: ({ payload }) => {
      // call umami specific page tracking
    },
    track: ({ payload }) => {
      // call umami event tracking
    },
    loaded: () => {
      // return boolean so analytics knows when it can send data to third party
      return !!window.myPluginLoaded
    }
  }
}
DavidWells commented 3 years ago

A consolidated issue has been created at https://github.com/DavidWells/analytics/issues/153 for plugin requests.

Feel free to comment/reopen this thread if you have begun active development on this plugin.