@bna/analytics-plugin-umami
TypeScript icon, indicating that this package has built-in type declarations

0.0.14 • Public • Published

Umami Analytics

This library exports the Umami plugin for the analytics package & standalone methods for any project to use to make it easier to interact with Umami Analytics.

How to use

Below is an example of how to use the browser plugin.

Using npm:

import Analytics from '@bna/analytics';
import umamiAnalytics from '@bna/analytics-plugin-umami';

const analytics = Analytics({
  app: 'awesome-app',
  plugins: [
    umamiAnalytics({
      id: '2455d925-489d-4d28-be36-ad43c144e6af',
      reportUri: 'https://your.umami.reportUri',
    }),
  ],
});

/* Track a page view */
analytics.page();

/* Track a custom event */
analytics.track('playedVideo', {
  category: 'Videos',
  label: 'Fall Campaign',
  value: 42,
});

/* export the instance for usage in your app */
export default analytics;

Using script tag:

<script src="../dist/umd/analytics-with-umami.min.js"></script>
<script type="text/javascript">
  var c = function (n, fns) {
    var _n = (window[n] = window[n] || {});
    for (var i = 0; i < fns.length; i++) {
      (function (_i) {
        var fn = fns[_i];
        _n[fn] ||
          (_n[fn] = function () {
            (_n[fn].q = _n[fn].q || []).push(arguments);
          });
      })(i);
    }
  };
  c('_analytics', ['init', 'track', 'page']);

  /* Initialize analytics */
  _analytics.init({
    id: '2455d925-489d-4d28-be36-ad43c144e6af',
    reportUri: 'http://localhost:3000',
  });

  _analytics.page();
</script>

/@bna/analytics-plugin-umami/

    Package Sidebar

    Install

    npm i @bna/analytics-plugin-umami

    Weekly Downloads

    0

    Version

    0.0.14

    License

    MIT

    Unpacked Size

    52.9 kB

    Total Files

    14

    Last publish

    Collaborators

    • robot-ux